Checks whether the given property path contains null or undefined within the given object.
Narrows the type of each property in the path from T | null | undefined to T.
There are two variants:
A simple function for direct calls (e.g. in if-statement-conditions). It asks for the object to check as well as the property path.
The second variant is a factory-function which only gets the property path. It returns a pre-configured predicate function for usage with functional calls like Array#filter.
Both variants have overloads with up to 5 properties to check.
Example:
const x: { a: { b: number | undefined } } = { a: { b: 1 } };
// simple usage: pass object and property path
if (isPathNotNil(x, 'a', 'b')) {
// type of x is now { a: { b: number } }
x.a.b.toFixed(3); // safe to access a and b
}
// array usage: just pass the properties to check
[x]
.filter(isPathNotNil('a', 'b'))
// type is now [{ a: { b: number } }]
.map(x => x.a.b.toFixed(3)) // safe to access a and b
With a path of just one property it does the same as isPropertyNotNil.
Checks whether the given property path contains null or undefined within the given object.
Narrows the type of each property in the path from T | null | undefined to T.
There are two variants:
A simple function for direct calls (e.g. in if-statement-conditions). It asks for the object to check as well as the property path.
The second variant is a factory-function which only gets the property path. It returns a pre-configured predicate function for usage with functional calls like Array#filter.
Both variants have overloads with up to 5 properties to check.
Example:
const x: { a: { b: number | undefined } } = { a: { b: 1 } };
// simple usage: pass object and property path
if (isPathNotNil(x, 'a', 'b')) {
// type of x is now { a: { b: number } }
x.a.b.toFixed(3); // safe to access a and b
}
// array usage: just pass the properties to check
[x]
.filter(isPathNotNil('a', 'b'))
// type is now [{ a: { b: number } }]
.map(x => x.a.b.toFixed(3)) // safe to access a and b
With a path of just one property it does the same as isPropertyNotNil.
Checks whether the given property path contains null or undefined within the given object.
Narrows the type of each property in the path from T | null | undefined to T.
There are two variants:
A simple function for direct calls (e.g. in if-statement-conditions). It asks for the object to check as well as the property path.
The second variant is a factory-function which only gets the property path. It returns a pre-configured predicate function for usage with functional calls like Array#filter.
Both variants have overloads with up to 5 properties to check.
Example:
const x: { a: { b: number | undefined } } = { a: { b: 1 } };
// simple usage: pass object and property path
if (isPathNotNil(x, 'a', 'b')) {
// type of x is now { a: { b: number } }
x.a.b.toFixed(3); // safe to access a and b
}
// array usage: just pass the properties to check
[x]
.filter(isPathNotNil('a', 'b'))
// type is now [{ a: { b: number } }]
.map(x => x.a.b.toFixed(3)) // safe to access a and b
With a path of just one property it does the same as isPropertyNotNil.
Checks whether the given property path contains null or undefined within the given object.
Narrows the type of each property in the path from T | null | undefined to T.
There are two variants:
A simple function for direct calls (e.g. in if-statement-conditions). It asks for the object to check as well as the property path.
The second variant is a factory-function which only gets the property path. It returns a pre-configured predicate function for usage with functional calls like Array#filter.
Both variants have overloads with up to 5 properties to check.
Example:
const x: { a: { b: number | undefined } } = { a: { b: 1 } };
// simple usage: pass object and property path
if (isPathNotNil(x, 'a', 'b')) {
// type of x is now { a: { b: number } }
x.a.b.toFixed(3); // safe to access a and b
}
// array usage: just pass the properties to check
[x]
.filter(isPathNotNil('a', 'b'))
// type is now [{ a: { b: number } }]
.map(x => x.a.b.toFixed(3)) // safe to access a and b
With a path of just one property it does the same as isPropertyNotNil.
Checks whether the given property path contains null or undefined within the given object.
Narrows the type of each property in the path from T | null | undefined to T.
There are two variants:
A simple function for direct calls (e.g. in if-statement-conditions). It asks for the object to check as well as the property path.
The second variant is a factory-function which only gets the property path. It returns a pre-configured predicate function for usage with functional calls like Array#filter.
Both variants have overloads with up to 5 properties to check.
Example:
const x: { a: { b: number | undefined } } = { a: { b: 1 } };
// simple usage: pass object and property path
if (isPathNotNil(x, 'a', 'b')) {
// type of x is now { a: { b: number } }
x.a.b.toFixed(3); // safe to access a and b
}
// array usage: just pass the properties to check
[x]
.filter(isPathNotNil('a', 'b'))
// type is now [{ a: { b: number } }]
.map(x => x.a.b.toFixed(3)) // safe to access a and b
With a path of just one property it does the same as isPropertyNotNil.
Checks whether the given property path contains null or undefined within the given object.
Narrows the type of each property in the path from T | null | undefined to T.
There are two variants:
A simple function for direct calls (e.g. in if-statement-conditions). It asks for the object to check as well as the property path.
The second variant is a factory-function which only gets the property path. It returns a pre-configured predicate function for usage with functional calls like Array#filter.
Both variants have overloads with up to 5 properties to check.
Example:
const x: { a: { b: number | undefined } } = { a: { b: 1 } };
// simple usage: pass object and property path
if (isPathNotNil(x, 'a', 'b')) {
// type of x is now { a: { b: number } }
x.a.b.toFixed(3); // safe to access a and b
}
// array usage: just pass the properties to check
[x]
.filter(isPathNotNil('a', 'b'))
// type is now [{ a: { b: number } }]
.map(x => x.a.b.toFixed(3)) // safe to access a and b
With a path of just one property it does the same as isPropertyNotNil.
Checks whether the given property path contains null or undefined within the given object.
Narrows the type of each property in the path from T | null | undefined to T.
There are two variants:
A simple function for direct calls (e.g. in if-statement-conditions). It asks for the object to check as well as the property path.
The second variant is a factory-function which only gets the property path. It returns a pre-configured predicate function for usage with functional calls like Array#filter.
Both variants have overloads with up to 5 properties to check.
Example:
const x: { a: { b: number | undefined } } = { a: { b: 1 } };
// simple usage: pass object and property path
if (isPathNotNil(x, 'a', 'b')) {
// type of x is now { a: { b: number } }
x.a.b.toFixed(3); // safe to access a and b
}
// array usage: just pass the properties to check
[x]
.filter(isPathNotNil('a', 'b'))
// type is now [{ a: { b: number } }]
.map(x => x.a.b.toFixed(3)) // safe to access a and b
With a path of just one property it does the same as isPropertyNotNil.
Checks whether the given property path contains null or undefined within the given object.
Narrows the type of each property in the path from T | null | undefined to T.
There are two variants:
A simple function for direct calls (e.g. in if-statement-conditions). It asks for the object to check as well as the property path.
The second variant is a factory-function which only gets the property path. It returns a pre-configured predicate function for usage with functional calls like Array#filter.
Both variants have overloads with up to 5 properties to check.
Example:
const x: { a: { b: number | undefined } } = { a: { b: 1 } };
// simple usage: pass object and property path
if (isPathNotNil(x, 'a', 'b')) {
// type of x is now { a: { b: number } }
x.a.b.toFixed(3); // safe to access a and b
}
// array usage: just pass the properties to check
[x]
.filter(isPathNotNil('a', 'b'))
// type is now [{ a: { b: number } }]
.map(x => x.a.b.toFixed(3)) // safe to access a and b
With a path of just one property it does the same as isPropertyNotNil.
Checks whether the given property path contains null or undefined within the given object.
Narrows the type of each property in the path from T | null | undefined to T.
There are two variants:
A simple function for direct calls (e.g. in if-statement-conditions). It asks for the object to check as well as the property path.
The second variant is a factory-function which only gets the property path. It returns a pre-configured predicate function for usage with functional calls like Array#filter.
Both variants have overloads with up to 5 properties to check.
Example:
const x: { a: { b: number | undefined } } = { a: { b: 1 } };
// simple usage: pass object and property path
if (isPathNotNil(x, 'a', 'b')) {
// type of x is now { a: { b: number } }
x.a.b.toFixed(3); // safe to access a and b
}
// array usage: just pass the properties to check
[x]
.filter(isPathNotNil('a', 'b'))
// type is now [{ a: { b: number } }]
.map(x => x.a.b.toFixed(3)) // safe to access a and b
With a path of just one property it does the same as isPropertyNotNil.
Checks whether the given property path contains
nullorundefinedwithin the given object. Narrows the type of each property in the path fromT | null | undefinedtoT.There are two variants:
A simple function for direct calls (e.g. in if-statement-conditions). It asks for the object to check as well as the property path.
The second variant is a factory-function which only gets the property path. It returns a pre-configured predicate function for usage with functional calls like Array#filter.
Both variants have overloads with up to 5 properties to check.
Example:
With a path of just one property it does the same as isPropertyNotNil.