Son CV dans un terminal web en Javascript! https://terminal-cv.gregandev.fr
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
terminal-cv/node_modules/utility-types/dist/aliases-and-guards.js

51 lines
1.7 KiB

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Tests for one of the [`Primitive`](https://developer.mozilla.org/en-US/docs/Glossary/Primitive) types using the JavaScript [`typeof`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof) operator
*
* Clarification: TypeScript overloads this operator to produce TypeScript types if used in context of types.
*
* @param val The value to be tested
* @returns If `val` is primitive. If used in the flow of the program typescript will infer type-information from this.
*
* @example
* const consumer = (value: Primitive | Primitive[]) => {
* if (isPrimitive(value)) {
* return console.log('Primitive value: ', value);
* }
* // type of value now inferred as Primitive[]
* value.map((primitive) => consumer(primitive));
* };
*/
exports.isPrimitive = function (val) {
if (val === null || val === undefined) {
return true;
}
switch (typeof val) {
case 'string':
case 'number':
case 'bigint':
case 'boolean':
case 'symbol': {
return true;
}
default:
return false;
}
};
/**
* Tests for Falsy by simply applying negation `!` to the tested `val`.
*
* The value is mostly in added type-information and explicity,
* but in case of this simple type much the same can often be archived by just using negation `!`:
* @example
* const consumer = (value: boolean | Falsy) => {
* if (!value) {
* return ;
* }
* type newType = typeof value; // === true
* // do stuff
* };
*/
exports.isFalsy = function (val) { return !val; };
//# sourceMappingURL=aliases-and-guards.js.map