{"_id":"@cjser/sindresorhus__is__v5_6_0","name":"@cjser/sindresorhus__is__v5_6_0","dist-tags":{"latest":"5.6.0-cjser.2"},"versions":{"5.6.0-cjser.2":{"name":"@cjser/sindresorhus__is__v5_6_0","version":"5.6.0-cjser.2","description":"Type check values","license":"MIT","repository":{"type":"git","url":"https://code.moenext.com/3rdeye/cjser.git"},"funding":"https://github.com/sindresorhus/is?sponsor=1","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"require":"./dist-cjser/index.cjs","default":"./dist/index.js"},"types":"./dist/index.d.ts","engines":{"node":">=14.16"},"scripts":{"build":"del dist && tsc","test":"tsc --noEmit && xo && ava"},"keywords":["type","types","is","check","checking","validate","validation","utility","util","typeof","instanceof","object","assert","assertion","test","kind","primitive","verify","compare","typescript","typeguards","types"],"devDependencies":{"@sindresorhus/tsconfig":"^3.0.1","@types/jsdom":"^21.1.1","@types/node":"^20.2.5","@types/zen-observable":"^0.8.3","ava":"^5.3.0","del-cli":"^5.0.0","jsdom":"^20.0.1","rxjs":"^7.8.1","tempy":"^3.0.0","ts-node":"^10.9.1","typescript":"^5.0.4","xo":"^0.54.2","zen-observable":"^0.10.0","expect-type":"^0.16.0"},"sideEffects":false,"ava":{"extensions":{"ts":"module"},"nodeArguments":["--loader=ts-node/esm"]},"main":"./dist-cjser/index.cjs","cjser":{"sourceVersion":"5.6.0","cjserVersion":2,"original":{"name":"@sindresorhus/is","version":"5.6.0","exports":"./dist/index.js","repository":"sindresorhus/is","files":["dist"],"scripts":{"build":"del dist && tsc","test":"tsc --noEmit && xo && ava","prepare":"npm run build"}}},"_id":"@cjser/sindresorhus__is__v5_6_0@5.6.0-cjser.2","gitHead":"a4bef54d7d22d3d9a6b84528457938d84cd65fe7","_nodeVersion":"20.14.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-NGVXWuOYHZ2RktXjFxoNgYsbNRXF5IaFrPtfH5eXyw5Z0IawRJzavdTtjaYVm1kDLtpB/2+zqm2LKQ24/BnWoQ==","shasum":"661b868c2e28ad179c45a09712c4b43d35724d8b","tarball":"https://registry.npmjs.org/@cjser/sindresorhus__is__v5_6_0/-/sindresorhus__is__v5_6_0-5.6.0-cjser.2.tgz","fileCount":8,"unpackedSize":82301,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDL2zVeXjTlmuqpMRwGWn/fwfikFs5wBHPn/gcVUweRMAiEA+YMmMb09CTVUhgI5UcxoLZr2PaEh+FC8D0mHx1Tk0V8="}]},"_npmUser":{"name":"nanahira","email":"nanahira@momobako.com"},"directories":{},"maintainers":[{"name":"nanahira","email":"nanahira@momobako.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sindresorhus__is__v5_6_0_5.6.0-cjser.2_1778160005262_0.59926340353296"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-07T13:20:05.181Z","5.6.0-cjser.2":"2026-05-07T13:20:05.413Z","modified":"2026-05-07T13:20:05.601Z"},"maintainers":[{"name":"nanahira","email":"nanahira@momobako.com"}],"description":"Type check values","keywords":["type","types","is","check","checking","validate","validation","utility","util","typeof","instanceof","object","assert","assertion","test","kind","primitive","verify","compare","typescript","typeguards","types"],"repository":{"type":"git","url":"https://code.moenext.com/3rdeye/cjser.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"license":"MIT","readme":"# is\n\n> Type check values\n\nFor example, `is.string('🦄') //=> true`\n\n<img src=\"header.gif\" width=\"182\" align=\"right\">\n\n## Highlights\n\n- Written in TypeScript\n- [Extensive use of type guards](#type-guards)\n- [Supports type assertions](#type-assertions)\n- [Aware of generic type parameters](#generic-type-parameters) (use with caution)\n- Actively maintained\n- ![Millions of downloads per week](https://img.shields.io/npm/dw/@sindresorhus/is)\n\n## Install\n\n```sh\nnpm install @sindresorhus/is\n```\n\n## Usage\n\n```js\nimport is from '@sindresorhus/is';\n\nis('🦄');\n//=> 'string'\n\nis(new Map());\n//=> 'Map'\n\nis.number(6);\n//=> true\n```\n\n[Assertions](#type-assertions) perform the same type checks, but throw an error if the type does not match.\n\n```js\nimport {assert} from '@sindresorhus/is';\n\nassert.string(2);\n//=> Error: Expected value which is `string`, received value of type `number`.\n```\n\nAnd with TypeScript:\n\n```ts\nimport {assert} from '@sindresorhus/is';\n\nassert.string(foo);\n// `foo` is now typed as a `string`.\n```\n\n## API\n\n### is(value)\n\nReturns the type of `value`.\n\nPrimitives are lowercase and object types are camelcase.\n\nExample:\n\n- `'undefined'`\n- `'null'`\n- `'string'`\n- `'symbol'`\n- `'Array'`\n- `'Function'`\n- `'Object'`\n\nNote: It will throw an error if you try to feed it object-wrapped primitives, as that's a bad practice. For example `new String('foo')`.\n\n### is.{method}\n\nAll the below methods accept a value and returns a boolean for whether the value is of the desired type.\n\n#### Primitives\n\n##### .undefined(value)\n##### .null(value)\n\n**Note:** TypeScript users must use `.null_()` because of a TypeScript naming limitation.\n\n##### .string(value)\n##### .number(value)\n\nNote: `is.number(NaN)` returns `false`. This intentionally deviates from `typeof` behavior to increase user-friendliness of `is` type checks.\n\n##### .boolean(value)\n##### .symbol(value)\n##### .bigint(value)\n\n#### Built-in types\n\n##### .array(value, assertion?)\n\nReturns true if `value` is an array and all of its items match the assertion (if provided).\n\n```js\nis.array(value); // Validate `value` is an array.\nis.array(value, is.number); // Validate `value` is an array and all of its items are numbers.\n```\n\n##### .function(value)\n\n**Note:** TypeScript users must use `.function_()` because of a TypeScript naming limitation.\n\n##### .buffer(value)\n##### .blob(value)\n##### .object(value)\n\nKeep in mind that [functions are objects too](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions).\n\n##### .numericString(value)\n\nReturns `true` for a string that represents a number satisfying `is.number`, for example, `'42'` and `'-8.3'`.\n\nNote: `'NaN'` returns `false`, but `'Infinity'` and `'-Infinity'` return `true`.\n\n##### .regExp(value)\n##### .date(value)\n##### .error(value)\n##### .nativePromise(value)\n##### .promise(value)\n\nReturns `true` for any object with a `.then()` and `.catch()` method. Prefer this one over `.nativePromise()` as you usually want to allow userland promise implementations too.\n\n##### .generator(value)\n\nReturns `true` for any object that implements its own `.next()` and `.throw()` methods and has a function definition for `Symbol.iterator`.\n\n##### .generatorFunction(value)\n\n##### .asyncFunction(value)\n\nReturns `true` for any `async` function that can be called with the `await` operator.\n\n```js\nis.asyncFunction(async () => {});\n//=> true\n\nis.asyncFunction(() => {});\n//=> false\n```\n\n##### .asyncGenerator(value)\n\n```js\nis.asyncGenerator(\n\t(async function * () {\n\t\tyield 4;\n\t})()\n);\n//=> true\n\nis.asyncGenerator(\n\t(function * () {\n\t\tyield 4;\n\t})()\n);\n//=> false\n```\n\n##### .asyncGeneratorFunction(value)\n\n```js\nis.asyncGeneratorFunction(async function * () {\n\tyield 4;\n});\n//=> true\n\nis.asyncGeneratorFunction(function * () {\n\tyield 4;\n});\n//=> false\n```\n\n##### .boundFunction(value)\n\nReturns `true` for any `bound` function.\n\n```js\nis.boundFunction(() => {});\n//=> true\n\nis.boundFunction(function () {}.bind(null));\n//=> true\n\nis.boundFunction(function () {});\n//=> false\n```\n\n##### .map(value)\n##### .set(value)\n##### .weakMap(value)\n##### .weakSet(value)\n##### .weakRef(value)\n\n#### Typed arrays\n\n##### .int8Array(value)\n##### .uint8Array(value)\n##### .uint8ClampedArray(value)\n##### .int16Array(value)\n##### .uint16Array(value)\n##### .int32Array(value)\n##### .uint32Array(value)\n##### .float32Array(value)\n##### .float64Array(value)\n##### .bigInt64Array(value)\n##### .bigUint64Array(value)\n\n#### Structured data\n\n##### .arrayBuffer(value)\n##### .sharedArrayBuffer(value)\n##### .dataView(value)\n\n##### .enumCase(value, enum)\n\nTypeScript-only. Returns `true` if `value` is a member of `enum`.\n\n```ts\nenum Direction {\n\tAscending = 'ascending',\n\tDescending = 'descending'\n}\n\nis.enumCase('ascending', Direction);\n//=> true\n\nis.enumCase('other', Direction);\n//=> false\n```\n\n#### Emptiness\n\n##### .emptyString(value)\n\nReturns `true` if the value is a `string` and the `.length` is 0.\n\n##### .emptyStringOrWhitespace(value)\n\nReturns `true` if `is.emptyString(value)` or if it's a `string` that is all whitespace.\n\n##### .nonEmptyString(value)\n\nReturns `true` if the value is a `string` and the `.length` is more than 0.\n\n##### .nonEmptyStringAndNotWhitespace(value)\n\nReturns `true` if the value is a `string` that is not empty and not whitespace.\n\n```js\nconst values = ['property1', '', null, 'property2', '    ', undefined];\n\nvalues.filter(is.nonEmptyStringAndNotWhitespace);\n//=> ['property1', 'property2']\n```\n\n##### .emptyArray(value)\n\nReturns `true` if the value is an `Array` and the `.length` is 0.\n\n##### .nonEmptyArray(value)\n\nReturns `true` if the value is an `Array` and the `.length` is more than 0.\n\n##### .emptyObject(value)\n\nReturns `true` if the value is an `Object` and `Object.keys(value).length` is 0.\n\nPlease note that `Object.keys` returns only own enumerable properties. Hence something like this can happen:\n\n```js\nconst object1 = {};\n\nObject.defineProperty(object1, 'property1', {\n\tvalue: 42,\n\twritable: true,\n\tenumerable: false,\n\tconfigurable: true\n});\n\nis.emptyObject(object1);\n//=> true\n```\n\n##### .nonEmptyObject(value)\n\nReturns `true` if the value is an `Object` and `Object.keys(value).length` is more than 0.\n\n##### .emptySet(value)\n\nReturns `true` if the value is a `Set` and the `.size` is 0.\n\n##### .nonEmptySet(Value)\n\nReturns `true` if the value is a `Set` and the `.size` is more than 0.\n\n##### .emptyMap(value)\n\nReturns `true` if the value is a `Map` and the `.size` is 0.\n\n##### .nonEmptyMap(value)\n\nReturns `true` if the value is a `Map` and the `.size` is more than 0.\n\n#### Miscellaneous\n\n##### .directInstanceOf(value, class)\n\nReturns `true` if `value` is a direct instance of `class`.\n\n```js\nis.directInstanceOf(new Error(), Error);\n//=> true\n\nclass UnicornError extends Error {}\n\nis.directInstanceOf(new UnicornError(), Error);\n//=> false\n```\n\n##### .urlInstance(value)\n\nReturns `true` if `value` is an instance of the [`URL` class](https://developer.mozilla.org/en-US/docs/Web/API/URL).\n\n```js\nconst url = new URL('https://example.com');\n\nis.urlInstance(url);\n//=> true\n```\n\n##### .urlString(value)\n\nReturns `true` if `value` is a URL string.\n\nNote: this only does basic checking using the [`URL` class](https://developer.mozilla.org/en-US/docs/Web/API/URL) constructor.\n\n```js\nconst url = 'https://example.com';\n\nis.urlString(url);\n//=> true\n\nis.urlString(new URL(url));\n//=> false\n```\n\n##### .truthy(value)\n\nReturns `true` for all values that evaluate to true in a boolean context:\n\n```js\nis.truthy('🦄');\n//=> true\n\nis.truthy(undefined);\n//=> false\n```\n\n##### .falsy(value)\n\nReturns `true` if `value` is one of: `false`, `0`, `''`, `null`, `undefined`, `NaN`.\n\n##### .nan(value)\n##### .nullOrUndefined(value)\n##### .primitive(value)\n\nJavaScript primitives are as follows: `null`, `undefined`, `string`, `number`, `boolean`, `symbol`.\n\n##### .integer(value)\n\n##### .safeInteger(value)\n\nReturns `true` if `value` is a [safe integer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger).\n\n##### .plainObject(value)\n\nAn object is plain if it's created by either `{}`, `new Object()`, or `Object.create(null)`.\n\n##### .iterable(value)\n##### .asyncIterable(value)\n##### .class(value)\n\nReturns `true` for instances created by a class.\n\n**Note:** TypeScript users must use `.class_()` because of a TypeScript naming limitation.\n\n##### .typedArray(value)\n\n##### .arrayLike(value)\n\nA `value` is array-like if it is not a function and has a `value.length` that is a safe integer greater than or equal to 0.\n\n```js\nis.arrayLike(document.forms);\n//=> true\n\nfunction foo() {\n\tis.arrayLike(arguments);\n\t//=> true\n}\nfoo();\n```\n\n##### .tupleLike(value, guards)\n\nA `value` is tuple-like if it matches the provided `guards` array both in `.length` and in types.\n\n```js\nis.tupleLike([1], [is.number]);\n//=> true\n```\n\n```js\nfunction foo() {\n\tconst tuple = [1, '2', true];\n\tif (is.tupleLike(tuple, [is.number, is.string, is.boolean])) {\n\t\ttuple // [number, string, boolean]\n\t}\n}\n\nfoo();\n```\n\n#### .positiveNumber(value)\n\nCheck if `value` is a number and is more than 0.\n\n#### .negativeNumber(value)\n\nCheck if `value` is a number and is less than 0.\n\n##### .inRange(value, range)\n\nCheck if `value` (number) is in the given `range`. The range is an array of two values, lower bound and upper bound, in no specific order.\n\n```js\nis.inRange(3, [0, 5]);\nis.inRange(3, [5, 0]);\nis.inRange(0, [-2, 2]);\n```\n\n##### .inRange(value, upperBound)\n\nCheck if `value` (number) is in the range of `0` to `upperBound`.\n\n```js\nis.inRange(3, 10);\n```\n\n##### .domElement(value)\n\nReturns `true` if `value` is a DOM Element.\n\n##### .nodeStream(value)\n\nReturns `true` if `value` is a Node.js [stream](https://nodejs.org/api/stream.html).\n\n```js\nimport fs from 'node:fs';\n\nis.nodeStream(fs.createReadStream('unicorn.png'));\n//=> true\n```\n\n##### .observable(value)\n\nReturns `true` if `value` is an `Observable`.\n\n```js\nimport {Observable} from 'rxjs';\n\nis.observable(new Observable());\n//=> true\n```\n\n##### .infinite(value)\n\nCheck if `value` is `Infinity` or `-Infinity`.\n\n##### .evenInteger(value)\n\nReturns `true` if `value` is an even integer.\n\n##### .oddInteger(value)\n\nReturns `true` if `value` is an odd integer.\n\n##### .propertyKey(value)\n\nReturns `true` if `value` can be used as an object property key (either `string`, `number`, or `symbol`).\n\n##### .formData(value)\n\nReturns `true` if `value` is an instance of the [`FormData` class](https://developer.mozilla.org/en-US/docs/Web/API/FormData).\n\n```js\nconst data = new FormData();\n\nis.formData(data);\n//=> true\n```\n\n##### .urlSearchParams(value)\n\nReturns `true` if `value` is an instance of the [`URLSearchParams` class](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams).\n\n```js\nconst searchParams = new URLSearchParams();\n\nis.urlSearchParams(searchParams);\n//=> true\n```\n\n##### .any(predicate | predicate[], ...values)\n\nUsing a single `predicate` argument, returns `true` if **any** of the input `values` returns true in the `predicate`:\n\n```js\nis.any(is.string, {}, true, '🦄');\n//=> true\n\nis.any(is.boolean, 'unicorns', [], new Map());\n//=> false\n```\n\nUsing an array of `predicate[]`, returns `true` if **any** of the input `values` returns true for **any** of the `predicates` provided in an array:\n\n```js\nis.any([is.string, is.number], {}, true, '🦄');\n//=> true\n\nis.any([is.boolean, is.number], 'unicorns', [], new Map());\n//=> false\n```\n\n##### .all(predicate, ...values)\n\nReturns `true` if **all** of the input `values` returns true in the `predicate`:\n\n```js\nis.all(is.object, {}, new Map(), new Set());\n//=> true\n\nis.all(is.string, '🦄', [], 'unicorns');\n//=> false\n```\n\n## Type guards\n\nWhen using `is` together with TypeScript, [type guards](http://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types) are being used extensively to infer the correct type inside if-else statements.\n\n```ts\nimport is from '@sindresorhus/is';\n\nconst padLeft = (value: string, padding: string | number) => {\n\tif (is.number(padding)) {\n\t\t// `padding` is typed as `number`\n\t\treturn Array(padding + 1).join(' ') + value;\n\t}\n\n\tif (is.string(padding)) {\n\t\t// `padding` is typed as `string`\n\t\treturn padding + value;\n\t}\n\n\tthrow new TypeError(`Expected 'padding' to be of type 'string' or 'number', got '${is(padding)}'.`);\n}\n\npadLeft('🦄', 3);\n//=> '   🦄'\n\npadLeft('🦄', '🌈');\n//=> '🌈🦄'\n```\n\n## Type assertions\n\nThe type guards are also available as [type assertions](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions), which throw an error for unexpected types. It is a convenient one-line version of the often repetitive \"if-not-expected-type-throw\" pattern.\n\n```ts\nimport {assert} from '@sindresorhus/is';\n\nconst handleMovieRatingApiResponse = (response: unknown) => {\n\tassert.plainObject(response);\n\t// `response` is now typed as a plain `object` with `unknown` properties.\n\n\tassert.number(response.rating);\n\t// `response.rating` is now typed as a `number`.\n\n\tassert.string(response.title);\n\t// `response.title` is now typed as a `string`.\n\n\treturn `${response.title} (${response.rating * 10})`;\n};\n\nhandleMovieRatingApiResponse({rating: 0.87, title: 'The Matrix'});\n//=> 'The Matrix (8.7)'\n\n// This throws an error.\nhandleMovieRatingApiResponse({rating: '🦄'});\n```\n\n## Generic type parameters\n\nThe type guards and type assertions are aware of [generic type parameters](https://www.typescriptlang.org/docs/handbook/generics.html), such as `Promise<T>` and `Map<Key, Value>`. The default is `unknown` for most cases, since `is` cannot check them at runtime. If the generic type is known at compile-time, either implicitly (inferred) or explicitly (provided), `is` propagates the type so it can be used later.\n\nUse generic type parameters with caution. They are only checked by the TypeScript compiler, and not checked by `is` at runtime. This can lead to unexpected behavior, where the generic type is _assumed_ at compile-time, but actually is something completely different at runtime. It is best to use `unknown` (default) and type-check the value of the generic type parameter at runtime with `is` or `assert`.\n\n```ts\nimport {assert} from '@sindresorhus/is';\n\nasync function badNumberAssumption(input: unknown) {\n\t// Bad assumption about the generic type parameter fools the compile-time type system.\n\tassert.promise<number>(input);\n\t// `input` is a `Promise` but only assumed to be `Promise<number>`.\n\n\tconst resolved = await input;\n\t// `resolved` is typed as `number` but was not actually checked at runtime.\n\n\t// Multiplication will return NaN if the input promise did not actually contain a number.\n\treturn 2 * resolved;\n}\n\nasync function goodNumberAssertion(input: unknown) {\n\tassert.promise(input);\n\t// `input` is typed as `Promise<unknown>`\n\n\tconst resolved = await input;\n\t// `resolved` is typed as `unknown`\n\n\tassert.number(resolved);\n\t// `resolved` is typed as `number`\n\n\t// Uses runtime checks so only numbers will reach the multiplication.\n\treturn 2 * resolved;\n}\n\nbadNumberAssumption(Promise.resolve('An unexpected string'));\n//=> NaN\n\n// This correctly throws an error because of the unexpected string value.\ngoodNumberAssertion(Promise.resolve('An unexpected string'));\n```\n\n## FAQ\n\n### Why yet another type checking module?\n\nThere are hundreds of type checking modules on npm, unfortunately, I couldn't find any that fit my needs:\n\n- Includes both type methods and ability to get the type\n- Types of primitives returned as lowercase and object types as camelcase\n- Covers all built-ins\n- Unsurprising behavior\n- Well-maintained\n- Comprehensive test suite\n\nFor the ones I found, pick 3 of these.\n\nThe most common mistakes I noticed in these modules was using `instanceof` for type checking, forgetting that functions are objects, and omitting `symbol` as a primitive.\n\n### Why not just use `instanceof` instead of this package?\n\n`instanceof` does not work correctly for all types and it does not work across [realms](https://stackoverflow.com/a/49832343/64949). Examples of realms are iframes, windows, web workers, and the `vm` module in Node.js.\n\n## For enterprise\n\nAvailable as part of the Tidelift Subscription.\n\nThe maintainers of @sindresorhus/is and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-sindresorhus-is?utm_source=npm-sindresorhus-is&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)\n\n## Related\n\n- [ow](https://github.com/sindresorhus/ow) - Function argument validation for humans\n- [is-stream](https://github.com/sindresorhus/is-stream) - Check if something is a Node.js stream\n- [is-observable](https://github.com/sindresorhus/is-observable) - Check if a value is an Observable\n- [file-type](https://github.com/sindresorhus/file-type) - Detect the file type of a Buffer/Uint8Array\n- [is-ip](https://github.com/sindresorhus/is-ip) - Check if a string is an IP address\n- [is-array-sorted](https://github.com/sindresorhus/is-array-sorted) - Check if an Array is sorted\n- [is-error-constructor](https://github.com/sindresorhus/is-error-constructor) - Check if a value is an error constructor\n- [is-empty-iterable](https://github.com/sindresorhus/is-empty-iterable) - Check if an Iterable is empty\n- [is-blob](https://github.com/sindresorhus/is-blob) - Check if a value is a Blob - File-like object of immutable, raw data\n- [has-emoji](https://github.com/sindresorhus/has-emoji) - Check whether a string has any emoji\n\n## Maintainers\n\n- [Sindre Sorhus](https://github.com/sindresorhus)\n- [Giora Guttsait](https://github.com/gioragutt)\n- [Brandon Smith](https://github.com/brandon93s)\n\n## cjser\n\nThis package is a CommonJS-compatible build generated by cjser for projects that still need `require()` support. The source version matches the original npm package version, with a cjser prerelease suffix for this generated build.\nOriginal repository: https://github.com/sindresorhus/is\n","readmeFilename":"readme.md","_rev":"1-97db82769d4ae993278b837f2c36fb13"}