is-any-array 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -29,7 +29,7 @@ isAnyArray(new Uint16Array(2))) // true;
29
29
 
30
30
  [npm-image]: https://img.shields.io/npm/v/is-any-array.svg
31
31
  [npm-url]: https://www.npmjs.com/package/is-any-array
32
- [build-image]: https://github.com/cheminfo/is-any-array/workflows/Node.js%20CI/badge.svg?branch=master
32
+ [build-image]: https://github.com/cheminfo/is-any-array/workflows/Node.js%20CI/badge.svg?branch=main
33
33
  [build-url]: https://github.com/cheminfo/is-any-array/actions?query=workflow%3A%22Node.js+CI%22
34
34
  [download-image]: https://img.shields.io/npm/dm/is-any-array.svg
35
35
  [download-url]: https://www.npmjs.com/package/is-any-array
package/lib/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
+ export type AnyArray = any[] | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
1
2
  /**
2
- * Checks if an object is an instance of an Array (array or typed array).
3
+ * Checks if an object is an instance of an Array (array or typed array, except those that contain bigint values).
3
4
  *
4
- * @param {any} value - Object to check.
5
- * @returns {boolean} True if the object is an array.
5
+ * @param value - Object to check.
6
+ * @returns True if the object is an array or a typed array.
6
7
  */
7
- export function isAnyArray(value: any): boolean;
8
+ export declare function isAnyArray(value: unknown): value is AnyArray;
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,kCAHW,GAAG,GACD,OAAO,CAInB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,QAAQ,GAChB,GAAG,EAAE,GACL,SAAS,GACT,UAAU,GACV,iBAAiB,GACjB,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,YAAY,GACZ,YAAY,CAAC;AAEjB;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAG5D"}
package/lib/index.js CHANGED
@@ -1,15 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isAnyArray = void 0;
4
+ // eslint-disable-next-line @typescript-eslint/unbound-method
4
5
  const toString = Object.prototype.toString;
5
6
  /**
6
- * Checks if an object is an instance of an Array (array or typed array).
7
+ * Checks if an object is an instance of an Array (array or typed array, except those that contain bigint values).
7
8
  *
8
- * @param {any} value - Object to check.
9
- * @returns {boolean} True if the object is an array.
9
+ * @param value - Object to check.
10
+ * @returns True if the object is an array or a typed array.
10
11
  */
11
12
  function isAnyArray(value) {
12
- return toString.call(value).endsWith('Array]');
13
+ const tag = toString.call(value);
14
+ return tag.endsWith('Array]') && !tag.includes('Big');
13
15
  }
14
16
  exports.isAnyArray = isAnyArray;
15
17
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";;;AAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;AAE3C;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,KAAK;IAC9B,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACjD,CAAC;AAFD,gCAEC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAA6D;AAC7D,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;AAc3C;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,KAAc;IACvC,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjC,OAAO,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC;AAHD,gCAGC"}
@@ -1,8 +1,9 @@
1
+ export type AnyArray = any[] | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
1
2
  /**
2
- * Checks if an object is an instance of an Array (array or typed array).
3
+ * Checks if an object is an instance of an Array (array or typed array, except those that contain bigint values).
3
4
  *
4
- * @param {any} value - Object to check.
5
- * @returns {boolean} True if the object is an array.
5
+ * @param value - Object to check.
6
+ * @returns True if the object is an array or a typed array.
6
7
  */
7
- export function isAnyArray(value: any): boolean;
8
+ export declare function isAnyArray(value: unknown): value is AnyArray;
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,kCAHW,GAAG,GACD,OAAO,CAInB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,QAAQ,GAChB,GAAG,EAAE,GACL,SAAS,GACT,UAAU,GACV,iBAAiB,GACjB,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,YAAY,GACZ,YAAY,CAAC;AAEjB;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAG5D"}
package/lib-esm/index.js CHANGED
@@ -1,11 +1,13 @@
1
+ // eslint-disable-next-line @typescript-eslint/unbound-method
1
2
  const toString = Object.prototype.toString;
2
3
  /**
3
- * Checks if an object is an instance of an Array (array or typed array).
4
+ * Checks if an object is an instance of an Array (array or typed array, except those that contain bigint values).
4
5
  *
5
- * @param {any} value - Object to check.
6
- * @returns {boolean} True if the object is an array.
6
+ * @param value - Object to check.
7
+ * @returns True if the object is an array or a typed array.
7
8
  */
8
9
  export function isAnyArray(value) {
9
- return toString.call(value).endsWith('Array]');
10
+ const tag = toString.call(value);
11
+ return tag.endsWith('Array]') && !tag.includes('Big');
10
12
  }
11
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,KAAK;IAC9B,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACjD,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;AAc3C;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjC,OAAO,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "is-any-array",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Check if a value is any kind of array",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib-esm/index.js",
@@ -21,9 +21,8 @@
21
21
  "tsc": "npm run clean && npm run tsc-cjs && npm run tsc-esm",
22
22
  "tsc-cjs": "tsc --project tsconfig.cjs.json",
23
23
  "tsc-esm": "tsc --project tsconfig.esm.json",
24
- "test": "npm run test-coverage && npm run eslint && npm run check-types",
25
- "test-coverage": "jest --coverage",
26
- "test-only": "jest"
24
+ "test": "npm run test-only && npm run eslint && npm run check-types",
25
+ "test-only": "jest --coverage"
27
26
  },
28
27
  "repository": {
29
28
  "type": "git",
@@ -37,13 +36,13 @@
37
36
  },
38
37
  "homepage": "https://github.com/cheminfo-js/is-any-array#readme",
39
38
  "devDependencies": {
40
- "@types/jest": "^27.0.2",
41
- "eslint": "^8.0.1",
42
- "eslint-config-cheminfo-typescript": "^10.1.1",
43
- "jest": "^27.2.5",
44
- "prettier": "^2.4.1",
45
- "rimraf": "^3.0.2",
46
- "ts-jest": "^27.0.6",
47
- "typescript": "^4.4.4"
39
+ "@types/jest": "^29.5.1",
40
+ "eslint": "^8.39.0",
41
+ "eslint-config-cheminfo-typescript": "^11.3.1",
42
+ "jest": "^29.5.0",
43
+ "prettier": "^2.8.8",
44
+ "rimraf": "^5.0.0",
45
+ "ts-jest": "^29.1.0",
46
+ "typescript": "^5.0.4"
48
47
  }
49
48
  }
@@ -8,4 +8,5 @@ test('isArray', () => {
8
8
  expect(isAnyArray([])).toBe(true);
9
9
  expect(isAnyArray([1, 2, 3])).toBe(true);
10
10
  expect(isAnyArray(new Uint16Array(2))).toBe(true);
11
+ expect(isAnyArray(new BigUint64Array(1))).toBe(false);
11
12
  });
package/src/index.ts ADDED
@@ -0,0 +1,25 @@
1
+ // eslint-disable-next-line @typescript-eslint/unbound-method
2
+ const toString = Object.prototype.toString;
3
+
4
+ export type AnyArray =
5
+ | any[] // eslint-disable-line @typescript-eslint/no-explicit-any
6
+ | Int8Array
7
+ | Uint8Array
8
+ | Uint8ClampedArray
9
+ | Int16Array
10
+ | Uint16Array
11
+ | Int32Array
12
+ | Uint32Array
13
+ | Float32Array
14
+ | Float64Array;
15
+
16
+ /**
17
+ * Checks if an object is an instance of an Array (array or typed array, except those that contain bigint values).
18
+ *
19
+ * @param value - Object to check.
20
+ * @returns True if the object is an array or a typed array.
21
+ */
22
+ export function isAnyArray(value: unknown): value is AnyArray {
23
+ const tag = toString.call(value);
24
+ return tag.endsWith('Array]') && !tag.includes('Big');
25
+ }
package/CHANGELOG.md DELETED
@@ -1,40 +0,0 @@
1
- # Changelog
2
-
3
- ## [2.0.0](https://www.github.com/cheminfo/is-any-array/compare/v1.0.1...v2.0.0) (2021-10-15)
4
-
5
-
6
- ### ⚠ BREAKING CHANGES
7
-
8
- When using this project you will need to use a named import: `import { isAnyArray } from 'is-any-array'`.
9
-
10
- ### Code Refactoring
11
-
12
- * setup project for TypeScript ([#7](https://www.github.com/cheminfo/is-any-array/issues/7)) ([21e47a0](https://www.github.com/cheminfo/is-any-array/commit/21e47a02e36987208b5aa22906c1cbfee3322775))
13
-
14
- ### [1.0.1](https://www.github.com/cheminfo/is-any-array/compare/v1.0.0...v1.0.1) (2021-06-30)
15
-
16
-
17
- ### Bug Fixes
18
-
19
- * rollup in dependencies ! ([7c26c34](https://www.github.com/cheminfo/is-any-array/commit/7c26c3416287c57eaeb9fc481fb2a7b107cfa984))
20
-
21
- ## [1.0.0](https://www.github.com/cheminfo/is-any-array/compare/v0.1.1...v1.0.0) (2021-03-24)
22
-
23
-
24
- ### Bug Fixes
25
-
26
- * update readme and dependencies ([7ae8169](https://www.github.com/cheminfo/is-any-array/commit/7ae8169b1105bc9e3586f6a73315897326bb1bd4))
27
-
28
- ### [0.1.1](https://github.com/cheminfo-js/is-any-array/compare/v0.1.0...v0.1.1) (2021-02-11)
29
-
30
- # [0.1.0](https://github.com/cheminfo-js/is-any-array/compare/v0.0.3...v0.1.0) (2020-02-25)
31
-
32
-
33
-
34
- <a name="0.0.3"></a>
35
- ## [0.0.3](https://github.com/cheminfo-js/is-any-array/compare/v0.0.2...v0.0.3) (2018-10-26)
36
-
37
-
38
-
39
- <a name="0.0.2"></a>
40
- ## 0.0.2 (2018-10-26)
package/src/index.js DELETED
@@ -1,11 +0,0 @@
1
- const toString = Object.prototype.toString;
2
-
3
- /**
4
- * Checks if an object is an instance of an Array (array or typed array).
5
- *
6
- * @param {any} value - Object to check.
7
- * @returns {boolean} True if the object is an array.
8
- */
9
- export function isAnyArray(value) {
10
- return toString.call(value).endsWith('Array]');
11
- }