devstar插件

This commit is contained in:
2025-07-26 16:40:29 +08:00
commit 30033daafe
4387 changed files with 1041101 additions and 0 deletions

21
node_modules/is-what/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Luca Ban - Mesqueeb
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

294
node_modules/is-what/README.md generated vendored Normal file
View File

@@ -0,0 +1,294 @@
# is What? 🙉
<a href="https://www.npmjs.com/package/is-what"><img src="https://img.shields.io/npm/v/is-what.svg" alt="Total Downloads"></a>
<a href="https://www.npmjs.com/package/is-what"><img src="https://img.shields.io/npm/dw/is-what.svg" alt="Latest Stable Version"></a>
Very simple & small JS type check functions. It's fully TypeScript supported!
```
npm i is-what
```
Or for deno available at: `"deno.land/x/is_what"`
> Also check out [is-where 🙈](https://github.com/mesqueeb/is-where)
## Motivation
I built is-what because the existing solutions were all too complex or too poorly built.
I was looking for:
- A simple way to check any kind of type (including non-primitives)
- Be able to check if an object is a plain object `{}` or a special object (like a class instance) ‼️
- Let TypeScript automatically know what type a value is when checking
And that's exactly what `is-what` is! (what a great wordplay 😃)
## Usage
is-what is really easy to use, and most functions work just like you'd expect.
```js
// import functions you want to use like so:
import { isString, isDate, isPlainObject } from 'is-what'
```
1. First I'll go over the simple functions available. Only `isNumber` and `isDate` have special treatment.
2. After that I'll talk about working with Objects (plain objects vs class instances etc.).
3. Lastly I'll talk about TypeScript implementation
### Simple type check functions
```js
// basics
isBoolean(true) // true
isBoolean(false) // true
isUndefined(undefined) // true
isNull(null) // true
// strings
isString('') // true
isEmptyString('') // true
isFullString('') // false
// numbers
isNumber(0) // true
isNumber('0') // false
isNumber(NaN) // false *
isPositiveNumber(1) // true
isNegativeNumber(-1) // true
// * see below for special NaN use cases!
// arrays
isArray([]) // true
isEmptyArray([]) // true
isFullArray([1]) // true
// objects
isPlainObject({}) // true *
isEmptyObject({}) // true
isFullObject({ a: 1 }) // true
// * see below for special object (& class instance) use cases!
// functions
isFunction(function () {}) // true
isFunction(() => {}) // true
// dates
isDate(new Date()) // true
isDate(new Date('invalid date')) // false
// maps & sets
isMap(new Map()) // true
isSet(new Set()) // true
isWeakMap(new WeakMap()) // true
isWeakSet(new WeakSet()) // true
// others
isRegExp(/\s/gi) // true
isSymbol(Symbol()) // true
isBlob(new Blob()) // true
isFile(new File([''], '', { type: 'text/html' })) // true
isError(new Error('')) // true
isPromise(new Promise((resolve) => {})) // true
// primitives
isPrimitive('') // true
// true for any of: boolean, null, undefined, number, string, symbol
```
### Let's talk about NaN
`isNaN` is a built-in JS Function but it really makes no sense:
```js
// 1)
typeof NaN === 'number' // true
// 🤔 ("not a number" is a "number"...)
// 2)
isNaN('1') // false
// 🤔 the string '1' is not-"not a number"... so it's a number??
// 3)
isNaN('one') // true
// 🤔 'one' is NaN but `NaN === 'one'` is false...
```
With is-what the way we treat NaN makes a little bit more sense:
```js
import { isNumber, isNaNValue } from 'is-what'
// 1)
isNumber(NaN) // false!
// let's not treat NaN as a number
// 2)
isNaNValue('1') // false
// if it's not NaN, it's not NaN!!
// 3)
isNaNValue('one') // false
// if it's not NaN, it's not NaN!!
isNaNValue(NaN) // true
```
### isPlainObject vs isAnyObject
Checking for a JavaScript object can be really difficult. In JavaScript you can create classes that will behave just like JavaScript objects but might have completely different prototypes. With is-what I went for this classification:
- `isPlainObject` will only return `true` on plain JavaScript objects and not on classes or others
- `isAnyObject` will be more loose and return `true` on regular objects, classes, etc.
```js
// define a plain object
const plainObject = { hello: 'I am a good old object.' }
// define a special object
class SpecialObject {
constructor(somethingSpecial) {
this.speciality = somethingSpecial
}
}
const specialObject = new SpecialObject('I am a special object! I am a class instance!!!')
// check the plain object
isPlainObject(plainObject) // returns true
isAnyObject(plainObject) // returns true
getType(plainObject) // returns 'Object'
// check the special object
isPlainObject(specialObject) // returns false !!!!!!!!!
isAnyObject(specialObject) // returns true
getType(specialObject) // returns 'Object'
```
> Please note that `isPlainObject` will only return `true` for normal plain JavaScript objects.
### Getting and checking for specific types
You can check for specific types with `getType` and `isType`:
```js
import { getType, isType } from 'is-what'
getType('') // returns 'String'
// pass a Type as second param:
isType('', String) // returns true
```
If you just want to make sure your object _inherits_ from a particular class or
`toStringTag` value, you can use `isInstanceOf()` like this:
```js
import { isInstanceOf } from 'is-what'
isInstanceOf(new XMLHttpRequest(), 'EventTarget')
// returns true
isInstanceOf(globalThis, ReadableStream)
// returns false
```
## TypeScript
is-what makes TypeScript know the type during if statements. This means that a check returns the type of the payload for TypeScript users.
```ts
function isNumber(payload: any): payload is number {
// return boolean
}
// As you can see above, all functions return a boolean for JavaScript, but pass the payload type to TypeScript.
// usage example:
function fn(payload: string | number): number {
if (isNumber(payload)) {
// ↑ TypeScript already knows payload is a number here!
return payload
}
return 0
}
```
`isPlainObject` and `isAnyObject` with TypeScript will declare the payload to be an object type with any props:
```ts
function isPlainObject(payload: any): payload is { [key: string]: any }
function isAnyObject(payload: any): payload is { [key: string]: any }
// The reason to return `{[key: string]: any}` is to be able to do
if (isPlainObject(payload) && payload.id) return payload.id
// if isPlainObject() would return `payload is object` then it would give an error at `payload.id`
```
### isObjectLike
If you want more control over what kind of interface/type is casted when checking for objects.
To cast to a specific type while checking for `isAnyObject`, can use `isObjectLike<T>`:
```ts
import { isObjectLike } from 'is-what'
const payload = { name: 'Mesqueeb' } // current type: `{ name: string }`
// Without casting:
if (isAnyObject(payload)) {
// in here `payload` is casted to: `Record<string | number | symbol, any>`
// WE LOOSE THE TYPE!
}
// With casting:
// you can pass a specific type for TS that will be casted when the function returns
if (isObjectLike<{ name: string }>(payload)) {
// in here `payload` is casted to: `{ name: string }`
}
```
Please note: this library will not actually check the shape of the object, you need to do that yourself.
`isObjectLike<T>` works like this under the hood:
```ts
function isObjectLike<T extends object>(payload: any): payload is T {
return isAnyObject(payload)
}
```
## Meet the family (more tiny utils with TS support)
- [is-what 🙉](https://github.com/mesqueeb/is-what)
- [is-where 🙈](https://github.com/mesqueeb/is-where)
- [merge-anything 🥡](https://github.com/mesqueeb/merge-anything)
- [check-anything 👁](https://github.com/mesqueeb/check-anything)
- [remove-anything ✂️](https://github.com/mesqueeb/remove-anything)
- [getorset-anything 🐊](https://github.com/mesqueeb/getorset-anything)
- [map-anything 🗺](https://github.com/mesqueeb/map-anything)
- [filter-anything ⚔️](https://github.com/mesqueeb/filter-anything)
- [copy-anything 🎭](https://github.com/mesqueeb/copy-anything)
- [case-anything 🐫](https://github.com/mesqueeb/case-anything)
- [flatten-anything 🏏](https://github.com/mesqueeb/flatten-anything)
- [nestify-anything 🧅](https://github.com/mesqueeb/nestify-anything)
## Source code
It's litterally just these functions:
```js
function getType(payload) {
return Object.prototype.toString.call(payload).slice(8, -1)
}
function isUndefined(payload) {
return getType(payload) === 'Undefined'
}
function isString(payload) {
return getType(payload) === 'String'
}
function isAnyObject(payload) {
return getType(payload) === 'Object'
}
// etc...
```
See the full source code [here](https://github.com/mesqueeb/is-what/blob/production/src/index.ts).

209
node_modules/is-what/dist/cjs/index.cjs generated vendored Normal file
View File

@@ -0,0 +1,209 @@
'use strict';
function getType(payload) {
return Object.prototype.toString.call(payload).slice(8, -1);
}
function isAnyObject(payload) {
return getType(payload) === "Object";
}
function isArray(payload) {
return getType(payload) === "Array";
}
function isBlob(payload) {
return getType(payload) === "Blob";
}
function isBoolean(payload) {
return getType(payload) === "Boolean";
}
function isDate(payload) {
return getType(payload) === "Date" && !isNaN(payload);
}
function isEmptyArray(payload) {
return isArray(payload) && payload.length === 0;
}
function isPlainObject(payload) {
if (getType(payload) !== "Object")
return false;
const prototype = Object.getPrototypeOf(payload);
return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
}
function isEmptyObject(payload) {
return isPlainObject(payload) && Object.keys(payload).length === 0;
}
function isEmptyString(payload) {
return payload === "";
}
function isError(payload) {
return getType(payload) === "Error" || payload instanceof Error;
}
function isFile(payload) {
return getType(payload) === "File";
}
function isFullArray(payload) {
return isArray(payload) && payload.length > 0;
}
function isFullObject(payload) {
return isPlainObject(payload) && Object.keys(payload).length > 0;
}
function isString(payload) {
return getType(payload) === "String";
}
function isFullString(payload) {
return isString(payload) && payload !== "";
}
function isFunction(payload) {
return typeof payload === "function";
}
function isType(payload, type) {
if (!(type instanceof Function)) {
throw new TypeError("Type must be a function");
}
if (!Object.prototype.hasOwnProperty.call(type, "prototype")) {
throw new TypeError("Type is not a class");
}
const name = type.name;
return getType(payload) === name || Boolean(payload && payload.constructor === type);
}
function isInstanceOf(value, classOrClassName) {
if (typeof classOrClassName === "function") {
for (let p = value; p; p = Object.getPrototypeOf(p)) {
if (isType(p, classOrClassName)) {
return true;
}
}
return false;
} else {
for (let p = value; p; p = Object.getPrototypeOf(p)) {
if (getType(p) === classOrClassName) {
return true;
}
}
return false;
}
}
function isMap(payload) {
return getType(payload) === "Map";
}
function isNaNValue(payload) {
return getType(payload) === "Number" && isNaN(payload);
}
function isNumber(payload) {
return getType(payload) === "Number" && !isNaN(payload);
}
function isNegativeNumber(payload) {
return isNumber(payload) && payload < 0;
}
function isNull(payload) {
return getType(payload) === "Null";
}
function isOneOf(a, b, c, d, e) {
return (value) => a(value) || b(value) || !!c && c(value) || !!d && d(value) || !!e && e(value);
}
function isUndefined(payload) {
return getType(payload) === "Undefined";
}
const isNullOrUndefined = isOneOf(isNull, isUndefined);
function isObject(payload) {
return isPlainObject(payload);
}
function isObjectLike(payload) {
return isAnyObject(payload);
}
function isPositiveNumber(payload) {
return isNumber(payload) && payload > 0;
}
function isSymbol(payload) {
return getType(payload) === "Symbol";
}
function isPrimitive(payload) {
return isBoolean(payload) || isNull(payload) || isUndefined(payload) || isNumber(payload) || isString(payload) || isSymbol(payload);
}
function isPromise(payload) {
return getType(payload) === "Promise";
}
function isRegExp(payload) {
return getType(payload) === "RegExp";
}
function isSet(payload) {
return getType(payload) === "Set";
}
function isWeakMap(payload) {
return getType(payload) === "WeakMap";
}
function isWeakSet(payload) {
return getType(payload) === "WeakSet";
}
exports.getType = getType;
exports.isAnyObject = isAnyObject;
exports.isArray = isArray;
exports.isBlob = isBlob;
exports.isBoolean = isBoolean;
exports.isDate = isDate;
exports.isEmptyArray = isEmptyArray;
exports.isEmptyObject = isEmptyObject;
exports.isEmptyString = isEmptyString;
exports.isError = isError;
exports.isFile = isFile;
exports.isFullArray = isFullArray;
exports.isFullObject = isFullObject;
exports.isFullString = isFullString;
exports.isFunction = isFunction;
exports.isInstanceOf = isInstanceOf;
exports.isMap = isMap;
exports.isNaNValue = isNaNValue;
exports.isNegativeNumber = isNegativeNumber;
exports.isNull = isNull;
exports.isNullOrUndefined = isNullOrUndefined;
exports.isNumber = isNumber;
exports.isObject = isObject;
exports.isObjectLike = isObjectLike;
exports.isOneOf = isOneOf;
exports.isPlainObject = isPlainObject;
exports.isPositiveNumber = isPositiveNumber;
exports.isPrimitive = isPrimitive;
exports.isPromise = isPromise;
exports.isRegExp = isRegExp;
exports.isSet = isSet;
exports.isString = isString;
exports.isSymbol = isSymbol;
exports.isType = isType;
exports.isUndefined = isUndefined;
exports.isWeakMap = isWeakMap;
exports.isWeakSet = isWeakSet;

380
node_modules/is-what/dist/cjs/index.d.cts generated vendored Normal file
View File

@@ -0,0 +1,380 @@
/**
* Returns the object type of the given payload
*
* @param {any} payload
* @returns {string}
*/
declare function getType(payload: any): string;
type PlainObject = Record<string | number | symbol, any>;
/**
* Returns whether the payload is a plain JavaScript object (excluding special classes or objects
* with other prototypes)
*
* @param {any} payload
* @returns {payload is PlainObject}
*/
declare function isPlainObject(payload: any): payload is PlainObject;
/**
* Returns whether the payload is an any kind of object (including special classes or objects with
* different prototypes)
*
* @param {any} payload
* @returns {payload is PlainObject}
*/
declare function isAnyObject(payload: any): payload is PlainObject;
/**
* Returns whether the payload is an array
*
* @param {any} payload
* @returns {payload is any[]}
*/
declare function isArray(payload: any): payload is any[];
/**
* Returns whether the payload is a Blob
*
* @param {any} payload
* @returns {payload is Blob}
*/
declare function isBlob(payload: any): payload is Blob;
/**
* Returns whether the payload is a boolean
*
* @param {any} payload
* @returns {payload is boolean}
*/
declare function isBoolean(payload: any): payload is boolean;
/**
* Returns whether the payload is a Date, and that the date is valid
*
* @param {any} payload
* @returns {payload is Date}
*/
declare function isDate(payload: any): payload is Date;
/**
* Returns whether the payload is a an empty array
*
* @param {any} payload
* @returns {payload is []}
*/
declare function isEmptyArray(payload: any): payload is [];
/**
* Returns whether the payload is a an empty object (excluding special classes or objects with other
* prototypes)
*
* @param {any} payload
* @returns {payload is { [K in any]: never }}
*/
declare function isEmptyObject(payload: any): payload is {
[K in any]: never;
};
/**
* Returns whether the payload is ''
*
* @param {any} payload
* @returns {payload is string}
*/
declare function isEmptyString(payload: any): payload is string;
/**
* Returns whether the payload is an Error
*
* @param {any} payload
* @returns {payload is Error}
*/
declare function isError(payload: any): payload is Error;
/**
* Returns whether the payload is a File
*
* @param {any} payload
* @returns {payload is File}
*/
declare function isFile(payload: any): payload is File;
/**
* Returns whether the payload is a an array with at least 1 item
*
* @param {any} payload
* @returns {payload is any[]}
*/
declare function isFullArray(payload: any): payload is any[];
/**
* Returns whether the payload is a an empty object (excluding special classes or objects with other
* prototypes)
*
* @param {any} payload
* @returns {payload is PlainObject}
*/
declare function isFullObject(payload: any): payload is PlainObject;
/**
* Returns whether the payload is a string, BUT returns false for ''
*
* @param {any} payload
* @returns {payload is string}
*/
declare function isFullString(payload: any): payload is string;
type AnyFunction = (...args: any[]) => any;
/**
* Returns whether the payload is a function (regular or async)
*
* @param {any} payload
* @returns {payload is AnyFunction}
*/
declare function isFunction(payload: any): payload is AnyFunction;
type AnyClass = new (...args: any[]) => any;
/**
* Does a generic check to check that the given payload is of a given type. In cases like Number, it
* will return true for NaN as NaN is a Number (thanks javascript!); It will, however, differentiate
* between object and null
*
* @template T
* @param {any} payload
* @param {T} type
* @returns {payload is T}
* @throws {TypeError} Will throw type error if type is an invalid type
*/
declare function isType<T extends AnyFunction | AnyClass>(payload: any, type: T): payload is T;
type GlobalClassName = {
[K in keyof typeof globalThis]: (typeof globalThis)[K] extends AnyClass ? K : never;
}[keyof typeof globalThis];
/**
* Checks if a value is an instance of a class or a class name. Useful when you want to check if a
* value is an instance of a class that may not be defined in the current scope. For example, if you
* want to check if a value is an `OffscreenCanvas` instance, you might not want to do the song and
* dance of using `typeof OffscreenCanvas !== 'undefined'` and then shimming `OffscreenCanvas` if
* the types aren't around.
*
* @example
* if (isInstanceOf(value, 'OffscreenCanvas')) {
* // value is an OffscreenCanvas
* }
*
* @param value The value to recursively check
* @param class_ A string or class that the value should be an instance of
*/
declare function isInstanceOf<T extends AnyClass>(value: unknown, class_: T): value is T;
declare function isInstanceOf<K extends GlobalClassName>(value: unknown, className: K): value is (typeof globalThis)[K];
declare function isInstanceOf(value: unknown, className: string): value is object;
/**
* Returns whether the payload is a Map
*
* @param {any} payload
* @returns {payload is Map<any, any>}
*/
declare function isMap(payload: any): payload is Map<any, any>;
/**
* Returns whether the payload is literally the value `NaN` (it's `NaN` and also a `number`)
*
* @param {any} payload
* @returns {payload is typeof NaN}
*/
declare function isNaNValue(payload: any): payload is typeof NaN;
/**
* Returns whether the payload is a negative number (but not 0)
*
* @param {any} payload
* @returns {payload is number}
*/
declare function isNegativeNumber(payload: any): payload is number;
/**
* Returns whether the payload is null
*
* @param {any} payload
* @returns {payload is null}
*/
declare function isNull(payload: any): payload is null;
/**
* Returns true whether the payload is null or undefined
*
* @param {any} payload
* @returns {(payload is null | undefined)}
*/
declare const isNullOrUndefined: (payload: any) => payload is null | undefined;
/**
* Returns whether the payload is a number (but not NaN)
*
* This will return `false` for `NaN`!!
*
* @param {any} payload
* @returns {payload is number}
*/
declare function isNumber(payload: any): payload is number;
/**
* Returns whether the payload is a plain JavaScript object (excluding special classes or objects
* with other prototypes)
*
* @param {any} payload
* @returns {payload is PlainObject}
*/
declare function isObject(payload: any): payload is PlainObject;
/**
* Returns whether the payload is an object like a type passed in < >
*
* Usage: isObjectLike<{id: any}>(payload) // will make sure it's an object and has an `id` prop.
*
* @template T This must be passed in < >
* @param {any} payload
* @returns {payload is T}
*/
declare function isObjectLike<T extends PlainObject>(payload: any): payload is T;
type TypeGuard<A, B extends A> = (payload: A) => payload is B;
/**
* A factory function that creates a function to check if the payload is one of the given types.
*
* @example
* import { isOneOf, isNull, isUndefined } from 'is-what'
*
* const isNullOrUndefined = isOneOf(isNull, isUndefined)
*
* isNullOrUndefined(null) // true
* isNullOrUndefined(undefined) // true
* isNullOrUndefined(123) // false
*/
declare function isOneOf<A, B extends A, C extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>): TypeGuard<A, B | C>;
/**
* A factory function that creates a function to check if the payload is one of the given types.
*
* @example
* import { isOneOf, isNull, isUndefined } from 'is-what'
*
* const isNullOrUndefined = isOneOf(isNull, isUndefined)
*
* isNullOrUndefined(null) // true
* isNullOrUndefined(undefined) // true
* isNullOrUndefined(123) // false
*/
declare function isOneOf<A, B extends A, C extends A, D extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>, c: TypeGuard<A, D>): TypeGuard<A, B | C | D>;
/**
* A factory function that creates a function to check if the payload is one of the given types.
*
* @example
* import { isOneOf, isNull, isUndefined } from 'is-what'
*
* const isNullOrUndefined = isOneOf(isNull, isUndefined)
*
* isNullOrUndefined(null) // true
* isNullOrUndefined(undefined) // true
* isNullOrUndefined(123) // false
*/
declare function isOneOf<A, B extends A, C extends A, D extends A, E extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>, c: TypeGuard<A, D>, d: TypeGuard<A, E>): TypeGuard<A, B | C | D | E>;
/**
* A factory function that creates a function to check if the payload is one of the given types.
*
* @example
* import { isOneOf, isNull, isUndefined } from 'is-what'
*
* const isNullOrUndefined = isOneOf(isNull, isUndefined)
*
* isNullOrUndefined(null) // true
* isNullOrUndefined(undefined) // true
* isNullOrUndefined(123) // false
*/
declare function isOneOf<A, B extends A, C extends A, D extends A, E extends A, F extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>, c: TypeGuard<A, D>, d: TypeGuard<A, E>, e: TypeGuard<A, F>): TypeGuard<A, B | C | D | E | F>;
/**
* Returns whether the payload is a positive number (but not 0)
*
* @param {any} payload
* @returns {payload is number}
*/
declare function isPositiveNumber(payload: any): payload is number;
/**
* Returns whether the payload is a primitive type (eg. Boolean | Null | Undefined | Number | String
* | Symbol)
*
* @param {any} payload
* @returns {(payload is boolean | null | undefined | number | string | symbol)}
*/
declare function isPrimitive(payload: any): payload is boolean | null | undefined | number | string | symbol;
/**
* Returns whether the payload is a Promise
*
* @param {any} payload
* @returns {payload is Promise<any>}
*/
declare function isPromise(payload: any): payload is Promise<any>;
/**
* Returns whether the payload is a regular expression (RegExp)
*
* @param {any} payload
* @returns {payload is RegExp}
*/
declare function isRegExp(payload: any): payload is RegExp;
/**
* Returns whether the payload is a Set
*
* @param {any} payload
* @returns {payload is Set<any>}
*/
declare function isSet(payload: any): payload is Set<any>;
/**
* Returns whether the payload is a string
*
* @param {any} payload
* @returns {payload is string}
*/
declare function isString(payload: any): payload is string;
/**
* Returns whether the payload is a Symbol
*
* @param {any} payload
* @returns {payload is symbol}
*/
declare function isSymbol(payload: any): payload is symbol;
/**
* Returns whether the payload is undefined
*
* @param {any} payload
* @returns {payload is undefined}
*/
declare function isUndefined(payload: any): payload is undefined;
/**
* Returns whether the payload is a WeakMap
*
* @param {any} payload
* @returns {payload is WeakMap<any, any>}
*/
declare function isWeakMap(payload: any): payload is WeakMap<any, any>;
/**
* Returns whether the payload is a WeakSet
*
* @param {any} payload
* @returns {payload is WeakSet<any>}
*/
declare function isWeakSet(payload: any): payload is WeakSet<any>;
type AnyAsyncFunction = (...args: any[]) => Promise<any>;
export { AnyAsyncFunction, AnyClass, AnyFunction, PlainObject, getType, isAnyObject, isArray, isBlob, isBoolean, isDate, isEmptyArray, isEmptyObject, isEmptyString, isError, isFile, isFullArray, isFullObject, isFullString, isFunction, isInstanceOf, isMap, isNaNValue, isNegativeNumber, isNull, isNullOrUndefined, isNumber, isObject, isObjectLike, isOneOf, isPlainObject, isPositiveNumber, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isType, isUndefined, isWeakMap, isWeakSet };

380
node_modules/is-what/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,380 @@
/**
* Returns the object type of the given payload
*
* @param {any} payload
* @returns {string}
*/
declare function getType(payload: any): string;
type PlainObject = Record<string | number | symbol, any>;
/**
* Returns whether the payload is a plain JavaScript object (excluding special classes or objects
* with other prototypes)
*
* @param {any} payload
* @returns {payload is PlainObject}
*/
declare function isPlainObject(payload: any): payload is PlainObject;
/**
* Returns whether the payload is an any kind of object (including special classes or objects with
* different prototypes)
*
* @param {any} payload
* @returns {payload is PlainObject}
*/
declare function isAnyObject(payload: any): payload is PlainObject;
/**
* Returns whether the payload is an array
*
* @param {any} payload
* @returns {payload is any[]}
*/
declare function isArray(payload: any): payload is any[];
/**
* Returns whether the payload is a Blob
*
* @param {any} payload
* @returns {payload is Blob}
*/
declare function isBlob(payload: any): payload is Blob;
/**
* Returns whether the payload is a boolean
*
* @param {any} payload
* @returns {payload is boolean}
*/
declare function isBoolean(payload: any): payload is boolean;
/**
* Returns whether the payload is a Date, and that the date is valid
*
* @param {any} payload
* @returns {payload is Date}
*/
declare function isDate(payload: any): payload is Date;
/**
* Returns whether the payload is a an empty array
*
* @param {any} payload
* @returns {payload is []}
*/
declare function isEmptyArray(payload: any): payload is [];
/**
* Returns whether the payload is a an empty object (excluding special classes or objects with other
* prototypes)
*
* @param {any} payload
* @returns {payload is { [K in any]: never }}
*/
declare function isEmptyObject(payload: any): payload is {
[K in any]: never;
};
/**
* Returns whether the payload is ''
*
* @param {any} payload
* @returns {payload is string}
*/
declare function isEmptyString(payload: any): payload is string;
/**
* Returns whether the payload is an Error
*
* @param {any} payload
* @returns {payload is Error}
*/
declare function isError(payload: any): payload is Error;
/**
* Returns whether the payload is a File
*
* @param {any} payload
* @returns {payload is File}
*/
declare function isFile(payload: any): payload is File;
/**
* Returns whether the payload is a an array with at least 1 item
*
* @param {any} payload
* @returns {payload is any[]}
*/
declare function isFullArray(payload: any): payload is any[];
/**
* Returns whether the payload is a an empty object (excluding special classes or objects with other
* prototypes)
*
* @param {any} payload
* @returns {payload is PlainObject}
*/
declare function isFullObject(payload: any): payload is PlainObject;
/**
* Returns whether the payload is a string, BUT returns false for ''
*
* @param {any} payload
* @returns {payload is string}
*/
declare function isFullString(payload: any): payload is string;
type AnyFunction = (...args: any[]) => any;
/**
* Returns whether the payload is a function (regular or async)
*
* @param {any} payload
* @returns {payload is AnyFunction}
*/
declare function isFunction(payload: any): payload is AnyFunction;
type AnyClass = new (...args: any[]) => any;
/**
* Does a generic check to check that the given payload is of a given type. In cases like Number, it
* will return true for NaN as NaN is a Number (thanks javascript!); It will, however, differentiate
* between object and null
*
* @template T
* @param {any} payload
* @param {T} type
* @returns {payload is T}
* @throws {TypeError} Will throw type error if type is an invalid type
*/
declare function isType<T extends AnyFunction | AnyClass>(payload: any, type: T): payload is T;
type GlobalClassName = {
[K in keyof typeof globalThis]: (typeof globalThis)[K] extends AnyClass ? K : never;
}[keyof typeof globalThis];
/**
* Checks if a value is an instance of a class or a class name. Useful when you want to check if a
* value is an instance of a class that may not be defined in the current scope. For example, if you
* want to check if a value is an `OffscreenCanvas` instance, you might not want to do the song and
* dance of using `typeof OffscreenCanvas !== 'undefined'` and then shimming `OffscreenCanvas` if
* the types aren't around.
*
* @example
* if (isInstanceOf(value, 'OffscreenCanvas')) {
* // value is an OffscreenCanvas
* }
*
* @param value The value to recursively check
* @param class_ A string or class that the value should be an instance of
*/
declare function isInstanceOf<T extends AnyClass>(value: unknown, class_: T): value is T;
declare function isInstanceOf<K extends GlobalClassName>(value: unknown, className: K): value is (typeof globalThis)[K];
declare function isInstanceOf(value: unknown, className: string): value is object;
/**
* Returns whether the payload is a Map
*
* @param {any} payload
* @returns {payload is Map<any, any>}
*/
declare function isMap(payload: any): payload is Map<any, any>;
/**
* Returns whether the payload is literally the value `NaN` (it's `NaN` and also a `number`)
*
* @param {any} payload
* @returns {payload is typeof NaN}
*/
declare function isNaNValue(payload: any): payload is typeof NaN;
/**
* Returns whether the payload is a negative number (but not 0)
*
* @param {any} payload
* @returns {payload is number}
*/
declare function isNegativeNumber(payload: any): payload is number;
/**
* Returns whether the payload is null
*
* @param {any} payload
* @returns {payload is null}
*/
declare function isNull(payload: any): payload is null;
/**
* Returns true whether the payload is null or undefined
*
* @param {any} payload
* @returns {(payload is null | undefined)}
*/
declare const isNullOrUndefined: (payload: any) => payload is null | undefined;
/**
* Returns whether the payload is a number (but not NaN)
*
* This will return `false` for `NaN`!!
*
* @param {any} payload
* @returns {payload is number}
*/
declare function isNumber(payload: any): payload is number;
/**
* Returns whether the payload is a plain JavaScript object (excluding special classes or objects
* with other prototypes)
*
* @param {any} payload
* @returns {payload is PlainObject}
*/
declare function isObject(payload: any): payload is PlainObject;
/**
* Returns whether the payload is an object like a type passed in < >
*
* Usage: isObjectLike<{id: any}>(payload) // will make sure it's an object and has an `id` prop.
*
* @template T This must be passed in < >
* @param {any} payload
* @returns {payload is T}
*/
declare function isObjectLike<T extends PlainObject>(payload: any): payload is T;
type TypeGuard<A, B extends A> = (payload: A) => payload is B;
/**
* A factory function that creates a function to check if the payload is one of the given types.
*
* @example
* import { isOneOf, isNull, isUndefined } from 'is-what'
*
* const isNullOrUndefined = isOneOf(isNull, isUndefined)
*
* isNullOrUndefined(null) // true
* isNullOrUndefined(undefined) // true
* isNullOrUndefined(123) // false
*/
declare function isOneOf<A, B extends A, C extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>): TypeGuard<A, B | C>;
/**
* A factory function that creates a function to check if the payload is one of the given types.
*
* @example
* import { isOneOf, isNull, isUndefined } from 'is-what'
*
* const isNullOrUndefined = isOneOf(isNull, isUndefined)
*
* isNullOrUndefined(null) // true
* isNullOrUndefined(undefined) // true
* isNullOrUndefined(123) // false
*/
declare function isOneOf<A, B extends A, C extends A, D extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>, c: TypeGuard<A, D>): TypeGuard<A, B | C | D>;
/**
* A factory function that creates a function to check if the payload is one of the given types.
*
* @example
* import { isOneOf, isNull, isUndefined } from 'is-what'
*
* const isNullOrUndefined = isOneOf(isNull, isUndefined)
*
* isNullOrUndefined(null) // true
* isNullOrUndefined(undefined) // true
* isNullOrUndefined(123) // false
*/
declare function isOneOf<A, B extends A, C extends A, D extends A, E extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>, c: TypeGuard<A, D>, d: TypeGuard<A, E>): TypeGuard<A, B | C | D | E>;
/**
* A factory function that creates a function to check if the payload is one of the given types.
*
* @example
* import { isOneOf, isNull, isUndefined } from 'is-what'
*
* const isNullOrUndefined = isOneOf(isNull, isUndefined)
*
* isNullOrUndefined(null) // true
* isNullOrUndefined(undefined) // true
* isNullOrUndefined(123) // false
*/
declare function isOneOf<A, B extends A, C extends A, D extends A, E extends A, F extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>, c: TypeGuard<A, D>, d: TypeGuard<A, E>, e: TypeGuard<A, F>): TypeGuard<A, B | C | D | E | F>;
/**
* Returns whether the payload is a positive number (but not 0)
*
* @param {any} payload
* @returns {payload is number}
*/
declare function isPositiveNumber(payload: any): payload is number;
/**
* Returns whether the payload is a primitive type (eg. Boolean | Null | Undefined | Number | String
* | Symbol)
*
* @param {any} payload
* @returns {(payload is boolean | null | undefined | number | string | symbol)}
*/
declare function isPrimitive(payload: any): payload is boolean | null | undefined | number | string | symbol;
/**
* Returns whether the payload is a Promise
*
* @param {any} payload
* @returns {payload is Promise<any>}
*/
declare function isPromise(payload: any): payload is Promise<any>;
/**
* Returns whether the payload is a regular expression (RegExp)
*
* @param {any} payload
* @returns {payload is RegExp}
*/
declare function isRegExp(payload: any): payload is RegExp;
/**
* Returns whether the payload is a Set
*
* @param {any} payload
* @returns {payload is Set<any>}
*/
declare function isSet(payload: any): payload is Set<any>;
/**
* Returns whether the payload is a string
*
* @param {any} payload
* @returns {payload is string}
*/
declare function isString(payload: any): payload is string;
/**
* Returns whether the payload is a Symbol
*
* @param {any} payload
* @returns {payload is symbol}
*/
declare function isSymbol(payload: any): payload is symbol;
/**
* Returns whether the payload is undefined
*
* @param {any} payload
* @returns {payload is undefined}
*/
declare function isUndefined(payload: any): payload is undefined;
/**
* Returns whether the payload is a WeakMap
*
* @param {any} payload
* @returns {payload is WeakMap<any, any>}
*/
declare function isWeakMap(payload: any): payload is WeakMap<any, any>;
/**
* Returns whether the payload is a WeakSet
*
* @param {any} payload
* @returns {payload is WeakSet<any>}
*/
declare function isWeakSet(payload: any): payload is WeakSet<any>;
type AnyAsyncFunction = (...args: any[]) => Promise<any>;
export { AnyAsyncFunction, AnyClass, AnyFunction, PlainObject, getType, isAnyObject, isArray, isBlob, isBoolean, isDate, isEmptyArray, isEmptyObject, isEmptyString, isError, isFile, isFullArray, isFullObject, isFullString, isFunction, isInstanceOf, isMap, isNaNValue, isNegativeNumber, isNull, isNullOrUndefined, isNumber, isObject, isObjectLike, isOneOf, isPlainObject, isPositiveNumber, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isType, isUndefined, isWeakMap, isWeakSet };

171
node_modules/is-what/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,171 @@
function getType(payload) {
return Object.prototype.toString.call(payload).slice(8, -1);
}
function isAnyObject(payload) {
return getType(payload) === "Object";
}
function isArray(payload) {
return getType(payload) === "Array";
}
function isBlob(payload) {
return getType(payload) === "Blob";
}
function isBoolean(payload) {
return getType(payload) === "Boolean";
}
function isDate(payload) {
return getType(payload) === "Date" && !isNaN(payload);
}
function isEmptyArray(payload) {
return isArray(payload) && payload.length === 0;
}
function isPlainObject(payload) {
if (getType(payload) !== "Object")
return false;
const prototype = Object.getPrototypeOf(payload);
return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
}
function isEmptyObject(payload) {
return isPlainObject(payload) && Object.keys(payload).length === 0;
}
function isEmptyString(payload) {
return payload === "";
}
function isError(payload) {
return getType(payload) === "Error" || payload instanceof Error;
}
function isFile(payload) {
return getType(payload) === "File";
}
function isFullArray(payload) {
return isArray(payload) && payload.length > 0;
}
function isFullObject(payload) {
return isPlainObject(payload) && Object.keys(payload).length > 0;
}
function isString(payload) {
return getType(payload) === "String";
}
function isFullString(payload) {
return isString(payload) && payload !== "";
}
function isFunction(payload) {
return typeof payload === "function";
}
function isType(payload, type) {
if (!(type instanceof Function)) {
throw new TypeError("Type must be a function");
}
if (!Object.prototype.hasOwnProperty.call(type, "prototype")) {
throw new TypeError("Type is not a class");
}
const name = type.name;
return getType(payload) === name || Boolean(payload && payload.constructor === type);
}
function isInstanceOf(value, classOrClassName) {
if (typeof classOrClassName === "function") {
for (let p = value; p; p = Object.getPrototypeOf(p)) {
if (isType(p, classOrClassName)) {
return true;
}
}
return false;
} else {
for (let p = value; p; p = Object.getPrototypeOf(p)) {
if (getType(p) === classOrClassName) {
return true;
}
}
return false;
}
}
function isMap(payload) {
return getType(payload) === "Map";
}
function isNaNValue(payload) {
return getType(payload) === "Number" && isNaN(payload);
}
function isNumber(payload) {
return getType(payload) === "Number" && !isNaN(payload);
}
function isNegativeNumber(payload) {
return isNumber(payload) && payload < 0;
}
function isNull(payload) {
return getType(payload) === "Null";
}
function isOneOf(a, b, c, d, e) {
return (value) => a(value) || b(value) || !!c && c(value) || !!d && d(value) || !!e && e(value);
}
function isUndefined(payload) {
return getType(payload) === "Undefined";
}
const isNullOrUndefined = isOneOf(isNull, isUndefined);
function isObject(payload) {
return isPlainObject(payload);
}
function isObjectLike(payload) {
return isAnyObject(payload);
}
function isPositiveNumber(payload) {
return isNumber(payload) && payload > 0;
}
function isSymbol(payload) {
return getType(payload) === "Symbol";
}
function isPrimitive(payload) {
return isBoolean(payload) || isNull(payload) || isUndefined(payload) || isNumber(payload) || isString(payload) || isSymbol(payload);
}
function isPromise(payload) {
return getType(payload) === "Promise";
}
function isRegExp(payload) {
return getType(payload) === "RegExp";
}
function isSet(payload) {
return getType(payload) === "Set";
}
function isWeakMap(payload) {
return getType(payload) === "WeakMap";
}
function isWeakSet(payload) {
return getType(payload) === "WeakSet";
}
export { getType, isAnyObject, isArray, isBlob, isBoolean, isDate, isEmptyArray, isEmptyObject, isEmptyString, isError, isFile, isFullArray, isFullObject, isFullString, isFunction, isInstanceOf, isMap, isNaNValue, isNegativeNumber, isNull, isNullOrUndefined, isNumber, isObject, isObjectLike, isOneOf, isPlainObject, isPositiveNumber, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isType, isUndefined, isWeakMap, isWeakSet };

128
node_modules/is-what/package.json generated vendored Normal file
View File

@@ -0,0 +1,128 @@
{
"name": "is-what",
"version": "4.1.16",
"description": "JS type check (TypeScript supported) functions like `isPlainObject() isArray()` etc. A simple & small integration.",
"type": "module",
"sideEffects": false,
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
"main": "./dist/index.js",
"exports": {
".": {
"require": {
"types": "./dist/cjs/index.d.cts",
"default": "./dist/cjs/index.cjs"
},
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
},
"files": [
"dist"
],
"engines": {
"node": ">=12.13"
},
"scripts": {
"test": "vitest run",
"lint": "tsc --noEmit && eslint ./src --ext .ts",
"build": "rollup -c ./rollup.config.js",
"build:docs": "typedoc",
"release": "npm run lint && del dist && npm run build && np"
},
"repository": {
"type": "git",
"url": "git+https://github.com/mesqueeb/is-what.git"
},
"keywords": [
"javascript",
"typescript",
"typechecker",
"check-type",
"javascript-type",
"primitive-types",
"plain-object",
"plain-objects",
"class-instance",
"class-identifier",
"type-checking",
"type-checker",
"type-check",
"define-type",
"get-type",
"what-type",
"is-object",
"is-plain-obj",
"is-plain-object"
],
"author": "Luca Ban - Mesqueeb",
"funding": "https://github.com/sponsors/mesqueeb",
"license": "MIT",
"bugs": {
"url": "https://github.com/mesqueeb/is-what/issues"
},
"homepage": "https://github.com/mesqueeb/is-what#readme",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"del-cli": "^5.1.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-tree-shaking": "^1.10.1",
"eslint": "^8.52.0",
"np": "^8.0.4",
"prettier-plugin-jsdoc": "^0.4.2",
"prettier": "^2.8.8",
"rollup-plugin-dts": "^5.3.1",
"rollup-plugin-esbuild": "^5.0.0",
"rollup": "^3.29.4",
"typedoc": "^0.25.2",
"typescript": "^5.2.2",
"vitest": "^0.34.6"
},
"np": {
"branch": "production",
"publish": false,
"yarn": false
},
"eslintConfig": {
"ignorePatterns": [
"node_modules",
"dist",
"scripts",
"test"
],
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"tree-shaking"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"rules": {
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"tree-shaking/no-side-effects-in-initialization": "error",
"@typescript-eslint/ban-ts-comment": "off"
}
},
"prettier": {
"printWidth": 100,
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "es5",
"semi": false,
"bracketSpacing": true,
"quoteProps": "consistent",
"plugins": [
"prettier-plugin-jsdoc"
]
}
}