debug

Asserts given conditions.

Type signature

(condition: boolean, callbackOrMessage?: (() => void) | string) => void;
export declare const throws: (f: () => void) => unknown | undefined;
export declare const assertNumber: (x?: unknown) => void;
export declare const assertInteger: (x?: unknown) => void;
export declare const assertByte: (x?: unknown) => void;
export declare const assertNormal: (x?: unknown) => void;
export declare const assertString: (x?: unknown, message?: string) => void;
export declare const assertIsDefined: (x?: unknown, message?: string) => void;
export default assert

Examples

assert(true === false);
// ⇒ TypeError("Assertion failed!")
Try in REPL

Questions

  • How to assert a condition?
  • How to throw when a condition is not satisfied?

TypeScript sourceJavaScript source

Computes a deep difference between the two values (primitives, objects, arrays, etc.).

Type signature

(obj1?: unknown, obj2?: unknown) => DiffResult;
export default diff

Examples

diff({ a: 1 }, { a: 2 });
// ⇒ { a: { data: [1, 2], type: '~' }}
Try in REPL

Questions

  • How to compute a diff?
  • How to compute a deep diff?
  • How to compute a diff between two objects?
  • How to compute a diff between two arrays?

TypeScript sourceJavaScript source