How to use updeep - 10 common examples

To help you get started, we’ve selected a few updeep examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github substantial / updeep / types / tests.ts View on Github external
u.ifElse(false as boolean, { a: 1 }, { a: 2 }, { a: 3 }); // $ExpectType object
u.ifElse(false as boolean, "foo", 3, { a: 3 }); // $ExpectType 3 | "foo"
u.ifElse(false, "foo", 3, { a: 3 }); // $ExpectType 3
u.ifElse(true, "foo", 3, { a: 3 }); // $ExpectType "foo"

// *** map ***
const inc = (i:number) => i+1;

u.map(inc, [1,2,3]); // $ExpectType number[]
u.map(inc, ["potato"]); // $ExpectType number[]
u.map({a:1},{a:2});  // $ExpectType Mapped<{ a: number; }, { a: number; }>

u.omit('bar', { }); // $ExpectType object
u.omit(['bar'], { }); // $ExpectType object

u.omitBy([ 'banana' ], { } ); // $ExpectError

// *** constant ***

// $ExpectType { banana: number; }
u.constant({ banana: 1 })('foo');

/// *** freeze ***

// $ExpectType { potato: number; }
u.freeze({ potato: 1 });
github substantial / updeep / types / tests.ts View on Github external
// *** map ***
const inc = (i:number) => i+1;

u.map(inc, [1,2,3]); // $ExpectType number[]
u.map(inc, ["potato"]); // $ExpectType number[]
u.map({a:1},{a:2});  // $ExpectType Mapped<{ a: number; }, { a: number; }>

u.omit('bar', { }); // $ExpectType object
u.omit(['bar'], { }); // $ExpectType object

u.omitBy([ 'banana' ], { } ); // $ExpectError

// *** constant ***

// $ExpectType { banana: number; }
u.constant({ banana: 1 })('foo');

/// *** freeze ***

// $ExpectType { potato: number; }
u.freeze({ potato: 1 });
github substantial / updeep / types / tests.ts View on Github external
u({ this: 2 })(true); // UpdateReturnMap<{ this: number; }>
u({ this: 2 })({ that: 3 }); // $ExpectType object


u.ifElse(false as boolean, { a: 1 }, { a: 2 }, { a: 3 }); // $ExpectType object
u.ifElse(false as boolean, "foo", 3, { a: 3 }); // $ExpectType 3 | "foo"
u.ifElse(false, "foo", 3, { a: 3 }); // $ExpectType 3
u.ifElse(true, "foo", 3, { a: 3 }); // $ExpectType "foo"

// *** map ***
const inc = (i:number) => i+1;

u.map(inc, [1,2,3]); // $ExpectType number[]
u.map(inc, ["potato"]); // $ExpectType number[]
u.map({a:1},{a:2});  // $ExpectType Mapped<{ a: number; }, { a: number; }>

u.omit('bar', { }); // $ExpectType object
u.omit(['bar'], { }); // $ExpectType object

u.omitBy([ 'banana' ], { } ); // $ExpectError

// *** constant ***

// $ExpectType { banana: number; }
u.constant({ banana: 1 })('foo');

/// *** freeze ***

// $ExpectType { potato: number; }
u.freeze({ potato: 1 });
github substantial / updeep / types / tests.ts View on Github external
u({ this: 2 })({ that: 3 }); // $ExpectType object

u({ this: 2 })(true); // UpdateReturnMap<{ this: number; }>
u({ this: 2 })({ that: 3 }); // $ExpectType object


u.ifElse(false as boolean, { a: 1 }, { a: 2 }, { a: 3 }); // $ExpectType object
u.ifElse(false as boolean, "foo", 3, { a: 3 }); // $ExpectType 3 | "foo"
u.ifElse(false, "foo", 3, { a: 3 }); // $ExpectType 3
u.ifElse(true, "foo", 3, { a: 3 }); // $ExpectType "foo"

// *** map ***
const inc = (i:number) => i+1;

u.map(inc, [1,2,3]); // $ExpectType number[]
u.map(inc, ["potato"]); // $ExpectType number[]
u.map({a:1},{a:2});  // $ExpectType Mapped<{ a: number; }, { a: number; }>

u.omit('bar', { }); // $ExpectType object
u.omit(['bar'], { }); // $ExpectType object

u.omitBy([ 'banana' ], { } ); // $ExpectError

// *** constant ***

// $ExpectType { banana: number; }
u.constant({ banana: 1 })('foo');

/// *** freeze ***

// $ExpectType { potato: number; }
u.freeze({ potato: 1 });
github substantial / updeep / types / tests.ts View on Github external
u((i: number) => "foo" + i, "bar");

// update is object
u({ this: 2 }, true); // $ExpectType UpdateReturnMap<{ this: number; }>
u({ this: 2 })(true); // $ExpectType UpdateReturnMap<{ this: number; }>

u({ this: 2 }, { this: 3 }); // $ExpectType object
u({ this: 2 })({ that: 3 }); // $ExpectType object

u({ this: 2 })(true); // UpdateReturnMap<{ this: number; }>
u({ this: 2 })({ that: 3 }); // $ExpectType object


u.ifElse(false as boolean, { a: 1 }, { a: 2 }, { a: 3 }); // $ExpectType object
u.ifElse(false as boolean, "foo", 3, { a: 3 }); // $ExpectType 3 | "foo"
u.ifElse(false, "foo", 3, { a: 3 }); // $ExpectType 3
u.ifElse(true, "foo", 3, { a: 3 }); // $ExpectType "foo"

// *** map ***
const inc = (i:number) => i+1;

u.map(inc, [1,2,3]); // $ExpectType number[]
u.map(inc, ["potato"]); // $ExpectType number[]
u.map({a:1},{a:2});  // $ExpectType Mapped<{ a: number; }, { a: number; }>

u.omit('bar', { }); // $ExpectType object
u.omit(['bar'], { }); // $ExpectType object

u.omitBy([ 'banana' ], { } ); // $ExpectError

// *** constant ***
github substantial / updeep / types / tests.ts View on Github external
u((i: number) => "foo" + i, 1); // $ExpecType string
u((i: number) => "foo" + i, "bar");

// update is object
u({ this: 2 }, true); // $ExpectType UpdateReturnMap<{ this: number; }>
u({ this: 2 })(true); // $ExpectType UpdateReturnMap<{ this: number; }>

u({ this: 2 }, { this: 3 }); // $ExpectType object
u({ this: 2 })({ that: 3 }); // $ExpectType object

u({ this: 2 })(true); // UpdateReturnMap<{ this: number; }>
u({ this: 2 })({ that: 3 }); // $ExpectType object


u.ifElse(false as boolean, { a: 1 }, { a: 2 }, { a: 3 }); // $ExpectType object
u.ifElse(false as boolean, "foo", 3, { a: 3 }); // $ExpectType 3 | "foo"
u.ifElse(false, "foo", 3, { a: 3 }); // $ExpectType 3
u.ifElse(true, "foo", 3, { a: 3 }); // $ExpectType "foo"

// *** map ***
const inc = (i:number) => i+1;

u.map(inc, [1,2,3]); // $ExpectType number[]
u.map(inc, ["potato"]); // $ExpectType number[]
u.map({a:1},{a:2});  // $ExpectType Mapped<{ a: number; }, { a: number; }>

u.omit('bar', { }); // $ExpectType object
u.omit(['bar'], { }); // $ExpectType object

u.omitBy([ 'banana' ], { } ); // $ExpectError
github substantial / updeep / types / tests.ts View on Github external
// update is object
u({ this: 2 }, true); // $ExpectType UpdateReturnMap<{ this: number; }>
u({ this: 2 })(true); // $ExpectType UpdateReturnMap<{ this: number; }>

u({ this: 2 }, { this: 3 }); // $ExpectType object
u({ this: 2 })({ that: 3 }); // $ExpectType object

u({ this: 2 })(true); // UpdateReturnMap<{ this: number; }>
u({ this: 2 })({ that: 3 }); // $ExpectType object


u.ifElse(false as boolean, { a: 1 }, { a: 2 }, { a: 3 }); // $ExpectType object
u.ifElse(false as boolean, "foo", 3, { a: 3 }); // $ExpectType 3 | "foo"
u.ifElse(false, "foo", 3, { a: 3 }); // $ExpectType 3
u.ifElse(true, "foo", 3, { a: 3 }); // $ExpectType "foo"

// *** map ***
const inc = (i:number) => i+1;

u.map(inc, [1,2,3]); // $ExpectType number[]
u.map(inc, ["potato"]); // $ExpectType number[]
u.map({a:1},{a:2});  // $ExpectType Mapped<{ a: number; }, { a: number; }>

u.omit('bar', { }); // $ExpectType object
u.omit(['bar'], { }); // $ExpectType object

u.omitBy([ 'banana' ], { } ); // $ExpectError

// *** constant ***

// $ExpectType { banana: number; }
github substantial / updeep / types / tests.ts View on Github external
u((i: number) => "foo" + i, 1); // $ExpecType string
u((i: number) => "foo" + i, "bar");

// update is object
u({ this: 2 }, true); // $ExpectType UpdateReturnMap<{ this: number; }>
u({ this: 2 })(true); // $ExpectType UpdateReturnMap<{ this: number; }>

u({ this: 2 }, { this: 3 }); // $ExpectType object
u({ this: 2 })({ that: 3 }); // $ExpectType object

u({ this: 2 })(true); // UpdateReturnMap<{ this: number; }>
u({ this: 2 })({ that: 3 }); // $ExpectType object


u.ifElse(false as boolean, { a: 1 }, { a: 2 }, { a: 3 }); // $ExpectType object
u.ifElse(false as boolean, "foo", 3, { a: 3 }); // $ExpectType 3 | "foo"
u.ifElse(false, "foo", 3, { a: 3 }); // $ExpectType 3
u.ifElse(true, "foo", 3, { a: 3 }); // $ExpectType "foo"

// *** map ***
const inc = (i:number) => i+1;

u.map(inc, [1,2,3]); // $ExpectType number[]
u.map(inc, ["potato"]); // $ExpectType number[]
u.map({a:1},{a:2});  // $ExpectType Mapped<{ a: number; }, { a: number; }>

u.omit('bar', { }); // $ExpectType object
u.omit(['bar'], { }); // $ExpectType object

u.omitBy([ 'banana' ], { } ); // $ExpectError

// *** constant ***
github substantial / updeep / types / tests.ts View on Github external
u.map({a:1},{a:2});  // $ExpectType Mapped<{ a: number; }, { a: number; }>

u.omit('bar', { }); // $ExpectType object
u.omit(['bar'], { }); // $ExpectType object

u.omitBy([ 'banana' ], { } ); // $ExpectError

// *** constant ***

// $ExpectType { banana: number; }
u.constant({ banana: 1 })('foo');

/// *** freeze ***

// $ExpectType { potato: number; }
u.freeze({ potato: 1 });
github substantial / updeep / types / tests.ts View on Github external
u.ifElse(false as boolean, { a: 1 }, { a: 2 }, { a: 3 }); // $ExpectType object
u.ifElse(false as boolean, "foo", 3, { a: 3 }); // $ExpectType 3 | "foo"
u.ifElse(false, "foo", 3, { a: 3 }); // $ExpectType 3
u.ifElse(true, "foo", 3, { a: 3 }); // $ExpectType "foo"

// *** map ***
const inc = (i:number) => i+1;

u.map(inc, [1,2,3]); // $ExpectType number[]
u.map(inc, ["potato"]); // $ExpectType number[]
u.map({a:1},{a:2});  // $ExpectType Mapped<{ a: number; }, { a: number; }>

u.omit('bar', { }); // $ExpectType object
u.omit(['bar'], { }); // $ExpectType object

u.omitBy([ 'banana' ], { } ); // $ExpectError

// *** constant ***

// $ExpectType { banana: number; }
u.constant({ banana: 1 })('foo');

/// *** freeze ***

// $ExpectType { potato: number; }
u.freeze({ potato: 1 });

updeep

Easily update nested frozen objects and arrays in a declarative and immutable manner.

MIT
Latest version published 2 years ago

Package Health Score

57 / 100
Full package analysis