Skip to content

Commit

Permalink
[adone] refactoring, fixes (DefinitelyTyped#23321)
Browse files Browse the repository at this point in the history
* refactoring, fixes
* add sprintf
* [assertion] replace assert properties with methods
* [assertion] is* -> *
* [data.json] add newline opt for encode
* [data.mpak] add tryDecode, add constructor opt for Serializer, add registerCommonTypesFor function
* [data.base64] add encoding param for decode
* [stream] make core a namespace, stream.core() -> core.create(), stream.CoreStream -> stream.core.Stream
* [fs] add readlinkSync, utimes, utimesSync, utimesMillis, readdirp, appendFIleSync, rmEmpty
* [fs] remove fd namespace, put everything into fs
* [fs] add mkdirSync, mkdirp, mkdirpSync
* [fs] fix copy, add copyTo
* [fs] pos options for tail
* [is] add type guards
* [promise] add props, retry
* [shani] add todo for it/describe
* [utils] remove mapArguments, functionParams, by, stripBom, GlobExp, sqlstring.(arrayToList, bufferToString objectToValues), buffer.(concat, mask, unmask), userid
* [utils] fix toposort, class ReInterval -> function reinterval, move throttle into its own namespace and add options, move RateLimiter to throttle
* [utils] add buffer.toArrayBuffer, buffer.xor, arrayDiff, fillRange, inflection, merge, omit, parseTime, pick, querystring, regexNot, repeat, signalNameToCode, splitBuffer, splitString, toRegex, xorDistance, braces, match

* event.EventEmitter -> event.Emitter
  • Loading branch information
am authored and sheetalkamat committed Jan 31, 2018
1 parent 83b24fb commit 366d972
Show file tree
Hide file tree
Showing 20 changed files with 3,102 additions and 1,095 deletions.
2 changes: 2 additions & 0 deletions types/adone/adone.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ declare namespace adone {
export function require(path: string): object;
export const package: object;

export function sprintf(format: string, ...args: any[]): string;

namespace I {
interface Runtime {
term: object; // TODO
Expand Down
2 changes: 1 addition & 1 deletion types/adone/glosses/archives.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ declare namespace adone {
isCompressed(): boolean;
}

interface ZipFile<StringType> extends event.EventEmitter {
interface ZipFile<StringType> extends event.Emitter {
/**
* true until close() is called; then it's false
*/
Expand Down
130 changes: 45 additions & 85 deletions types/adone/glosses/assertion.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,10 @@ declare namespace adone {
* Throws an AssertionError, like node.js
*/
fail(actual?: any, expected?: any, message?: string, operator?: any): void;
/**
* Asserts that value is truthy
*/
isOk(value: any, message?: string): void;
/**
* Asserts that value is truthy
*/
ok(value: any, message?: string): void;
/**
* Asserts that value is falsy
*/
isNotOk(value: any, message?: string): void;
/**
* Asserts that value is falsy
*/
Expand Down Expand Up @@ -104,51 +96,51 @@ declare namespace adone {
/**
* Asserts that value > above
*/
isAbove(value: any, above: any, message?: string): void;
above(value: any, above: any, message?: string): void;
/**
* Asserts that value >= atLeast
*/
isAtLeast(value: any, atLeast: any, message?: string): void;
atLeast(value: any, atLeast: any, message?: string): void;
/**
* Asserts that value < below
*/
isBelow(value: any, below: any, message?: string): void;
below(value: any, below: any, message?: string): void;
/**
* Asserts that value <= atMost
*/
isAtMost(value: any, atMost: any, message?: string): void;
atMost(value: any, atMost: any, message?: string): void;
/**
* Asserts that value is true
*/
isTrue(value: any, message?: string): void;
true(value: any, message?: string): void;
/**
* Asserts that value is not true
*/
isNotTrue(value: any, message?: string): void;
notTrue(value: any, message?: string): void;
/**
* Asserts that value is false
*/
isFalse(value: any, message?: string): void;
false(value: any, message?: string): void;
/**
* Asserts that value is not false
*/
isNotFalse(value: any, message?: string): void;
notFalse(value: any, message?: string): void;
/**
* Asserts that value is null
*/
isNull(value: any, message?: string): void;
null(value: any, message?: string): void;
/**
* Asserts that valus is not null
*/
isNotNull(value: any, message?: string): void;
notNull(value: any, message?: string): void;
/**
* Asserts that value is NaN
*/
isNaN(value: any, message?: string): void;
NaN(value: any, message?: string): void;
/**
* Asserts that value is not NaN
*/
isNotNaN(value: any, message?: string): void;
NotNaN(value: any, message?: string): void;
/**
* Asserts that value is neither null nor undefined
*/
Expand All @@ -160,63 +152,63 @@ declare namespace adone {
/**
* Asserts that value is undefined
*/
isUndefined(value: any, message?: string): void;
undefined(value: any, message?: string): void;
/**
* Asserts that value is not undefined
*/
isDefined(value: any, message?: string): void;
defined(value: any, message?: string): void;
/**
* Asserts that value is a function
*/
isFunction(value: any, message?: string): void;
function(value: any, message?: string): void;
/**
* Asserts that value is not a function
*/
isNotFunction(value: any, message?: string): void;
notFunction(value: any, message?: string): void;
/**
* Asserts that value is an object of type Object
*/
isObject(value: any, message?: string): void;
object(value: any, message?: string): void;
/**
* Asserts that value is not an object of type Object
*/
isNotObject(value: any, message?: string): void;
notObject(value: any, message?: string): void;
/**
* Asserts that value is an array
*/
isArray(value: any, message?: string): void;
array(value: any, message?: string): void;
/**
* Asserts that value is not an array
*/
isNotArray(value: any, message?: string): void;
notArray(value: any, message?: string): void;
/**
* Asserts that value is a string
*/
isString(value: any, message?: string): void;
string(value: any, message?: string): void;
/**
* Asserts that value is not a string
*/
isNotString(value: any, message?: string): void;
notString(value: any, message?: string): void;
/**
* Asserts that value is a number
*/
isNumber(value: any, message?: string): void;
number(value: any, message?: string): void;
/**
* Asserts that value is not a number
*/
isNotNumber(value: any, message?: string): void;
notNumber(value: any, message?: string): void;
/**
* Asserts that value is a finite number
*/
isFinite(value: any, message?: string): void;
finite(value: any, message?: string): void;
/**
* Asserts that value is a boolean
*/
isBoolean(value: any, message?: string): void;
boolean(value: any, message?: string): void;
/**
* Asserts that value is not a boolean
*/
isNotBoolean(value: any, message?: string): void;
notBoolean(value: any, message?: string): void;
/**
* Asserts that value's type is `type`
*/
Expand Down Expand Up @@ -562,66 +554,34 @@ declare namespace adone {
* Throws an error if value is truthy
*/
ifError(value: any): void;
/**
* Asserts that object is extensible
*/
isExtensible(object: object, message?: string): void;
/**
* Asserts that object is extensible
*/
extensible(object: object, message?: string): void;
/**
* Asserts that object is not extensible
*/
isNotExtensible(object: object, message?: string): void;
/**
* Asserts that object is not extensible
*/
notExtensible(object: object, message?: string): void;
/**
* Asserts that object is sealed
*/
isSealed(object: object, message?: string): void;
/**
* Asserts that object is sealed
*/
sealed(object: object, message?: string): void;
/**
* Asserts that object is not sealed
*/
isNotSealed(object: object, message?: string): void;
/**
* Asserts that object is not sealed
*/
notSealed(object: object, message?: string): void;
/**
* Asserts that object is frozen
*/
isFrozen(object: object, message?: string): void;
/**
* Asserts that object is frozen
*/
frozen(object: object, message?: string): void;
/**
* Asserts that object is not frozen
*/
isNotFrozen(object: object, message?: string): void;
/**
* Asserts that object is not frozen
*/
notFrozen(object: object, message?: string): void;
/**
* Asserts that value is empty
*/
isEmpty(value: any, message?: string): void;
/**
* Asserts that value is empty
*/
empty(value: any, message?: string): void;
/**
* Asserts that value is not empty
*/
isNotEmpty(value: any, message?: string): void;
/**
* Asserts that value is not empty
*/
Expand Down Expand Up @@ -710,43 +670,43 @@ declare namespace adone {
/**
* Asserts that the target is non-strictly equal to true
*/
ok: this;
ok(): this;
/**
* Asserts that the target is true
*/
true: this;
true(): this;
/**
* Asserts that the target is false
*/
false: this;
false(): this;
/**
* Asserts that the target is null
*/
null: this;
null(): this;
/**
* Asserts that the target is undefined
*/
undefined: this;
undefined(): this;
/**
* Asserts that the target is NaN
*/
NaN: this;
NaN(): this;
/**
* Asserts that the target is neither null nor undefined
*/
exist: this;
exist(): this;
/**
* Asserts that the target is empty
*/
empty: this;
empty(): this;
/**
* Asserts that the target is an arguments object
*/
arguments: this;
arguments(): this;
/**
* Asserts that the target is an arguments object
*/
Arguments: this;
Arguments(): this;
/**
* Asserts that the target is strictly equal to value(===)
*/
Expand Down Expand Up @@ -976,42 +936,42 @@ declare namespace adone {
/**
* Asserts that the target is extensible
*/
extensible: this;
extensible(): this;
/**
* Asserts that the target is sealed
*/
sealed: this;
sealed(): this;
/**
* Asserts that the target is frozen
*/
frozen: this;
frozen(): this;
/**
* Asserts that the target is a finite number
*/
finite: this;
finite(): this;
}

interface MockAssertions extends Assertion {
/**
* Asserts that the spy has been called
*/
called: this;
called(): this;
/**
* Asserts that the spy has been called n times
*/
callCount(n: number): this;
/**
* Asserts that the spy has been called once
*/
calledOnce: this;
calledOnce(): this;
/**
* Asserts that the spy has been called twice
*/
calledTwice: this;
calledTwice(): this;
/**
* Asserts that the spy has been been called with `new`
*/
calledThrice: this;
calledThrice(): this;
/**
* Asserts that the spy has been called before anotherSpy
*/
Expand Down
Loading

0 comments on commit 366d972

Please sign in to comment.