Package Exports
- payload-is
- payload-is/lib/commonjs/index.js
- payload-is/lib/module/index.js
- payload-is/src/index.ts
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (payload-is) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Payload is ?
Javascript Data Check (Typescript)
📝 Table of Contents
🧐 About
简洁的 JS (Javascript)数据校验方法。支持 Typescript。无其他依赖。
🏁 Getting Started
Installing
npm install payload-isUsage
import { isObject, isPlainObject } from "payload-is";// array
isArray([]); // true
isEmptyArray([]); // true
isFullArray([1]); // true
// bigint
isBigInt(1n); // true
isBigIntObject(Object(1n)); // true
// boolean
isBoolen(true); // true
isBooleanObject(new Boolean(true)); // true
isTrue(true); // true
isFalse(false); // true
// collection
isSet(new Set()); // true
isMap(new Map()); // true
isWeakSet(new WeakSet()); // true
isWeakMap(new WeakMap()); // true
isWeakRef(new WeakRef()); // true
// date
isDate(new Date()); //true
isValidDate(new Date(2022, 2, 22)); // true
isInvalidDate(new Date("InvalidDate")); // true
// error
isError(new Error("mesage")); //true
isEvalError(new EvalError("mesage"));
isRangeError(new RangeError("mesage"));
isReferenceError(new ReferenceError("mesage"));
isSyntaxError(new SyntaxError("mesage"));
isTypeError(new TypeError("mesage"));
isURIError(new URIError("mesage"));
// EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,
isNativeError(new SyntaxError("message")); // true
// function
isFunction(function () {}); // true;
isAsyncFunction(async function () {}); // true
isAsyncGeneratorFunction(async function* () {}); // true
isGeneratorFunction(function* () {}); // true
// generator
isGenerator((function* () {})()); // true
isAsyncGenerator((async function* () {})()); // true
// iterable
isIterable(new Set()); // true
isIterable(new Map()); // true
isAsyncIterable((async function* () {})()); // true
// nil
isNil(null); // true
isNil(undefined); // true
isNull(null); // true
isUndefined(undefined); // true
// number
isNumber(10); // true
isValidNumber(10); // true
isInvalidNumber(NAN); // true
isNumberObject(new Number(10)); // true
// object
isObject({}); // true
isPlainObject({}); // true
isEmptyObject({}); // true
isFullObject({ key: "abc" }); // true
// primitive
isPrimitive(1); // true
isPrimitive(null); // true
isPrimitive(undefined); // true
// promise
isPromise(new Promise(() => {})); // true
isPromiseLike({ then() {} }); // true
// regexp
isRegExp(/\d+/); // true
isRegExp(new RegExp("abc")); // true
// string
isString(""); // true
isEmptyString(""); // true
isFullString(" "); // true
isStringObject(new String("")); // true
// symbol
isSymbol(Symbol()); // true
isSymbolObject(Object(Symbol("object"))); // true
// buffer
isArrayBuffer(new ArrayBuffer(32)); // true
isSharedArrayBuffer(new SharedArrayBuffer(32)); // true
isArrayBufferLike(new ArrayBuffer(32)); // true
isArrayBufferLike(new SharedArrayBuffer(32)); // true
isDataView(new DataView(new ArrayBuffer(32))); // true
isInt8Array(new Int8Array(32)); // true
isUint8Array(new Uint8Array(32)); // true
isUint8ClampedArray(new Uint8ClampedArray(32)); // true
isInt16Array(new Int16Array(32)); // true
isUint16Array(new Uint16Array(32)); // true
isInt32Array(new Int32Array(32)); // true
isUint32Array(new Uint32Array(32)); // true
isFloat32Array(new Float32Array(32)); // true
isFloat64Array(new Float64Array(32)); // true
isBigInt64Array(new BigInt64Array(32)); // true
isBigUint64Array(new BigUint64Array(32)); // true
// Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array
isTypedArray(new Int8Array(32)); // true🔧 Running the tests
npm run test✍️ Authors
- @Hong Liu - Idea & Initial work
