is-any-array 1.0.1 → 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
@@ -13,7 +13,7 @@ Check if a value is any kind of array.
13
13
  ## Example
14
14
 
15
15
  ```js
16
- const isAnyArray = require('is-any-array');
16
+ const {isAnyArray} = require('is-any-array');
17
17
 
18
18
  isAnyArray(1); // false
19
19
  isAnyArray('ab'); // false
@@ -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 ADDED
@@ -0,0 +1,9 @@
1
+ export type AnyArray = any[] | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
2
+ /**
3
+ * Checks if an object is an instance of an Array (array or typed array, except those that contain bigint values).
4
+ *
5
+ * @param value - Object to check.
6
+ * @returns True if the object is an array or a typed array.
7
+ */
8
+ export declare function isAnyArray(value: unknown): value is AnyArray;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
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,11 +1,17 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAnyArray = void 0;
4
+ // eslint-disable-next-line @typescript-eslint/unbound-method
5
5
  const toString = Object.prototype.toString;
6
-
7
- function isAnyArray(object) {
8
- return toString.call(object).endsWith('Array]');
6
+ /**
7
+ * Checks if an object is an instance of an Array (array or typed array, except those that contain bigint values).
8
+ *
9
+ * @param value - Object to check.
10
+ * @returns True if the object is an array or a typed array.
11
+ */
12
+ function isAnyArray(value) {
13
+ const tag = toString.call(value);
14
+ return tag.endsWith('Array]') && !tag.includes('Big');
9
15
  }
10
-
11
- exports['default'] = isAnyArray;
16
+ exports.isAnyArray = isAnyArray;
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,9 @@
1
+ export type AnyArray = any[] | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
2
+ /**
3
+ * Checks if an object is an instance of an Array (array or typed array, except those that contain bigint values).
4
+ *
5
+ * @param value - Object to check.
6
+ * @returns True if the object is an array or a typed array.
7
+ */
8
+ export declare function isAnyArray(value: unknown): value is AnyArray;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,13 @@
1
+ // eslint-disable-next-line @typescript-eslint/unbound-method
2
+ const toString = Object.prototype.toString;
3
+ /**
4
+ * Checks if an object is an instance of an Array (array or typed array, except those that contain bigint values).
5
+ *
6
+ * @param value - Object to check.
7
+ * @returns True if the object is an array or a typed array.
8
+ */
9
+ export function isAnyArray(value) {
10
+ const tag = toString.call(value);
11
+ return tag.endsWith('Array]') && !tag.includes('Big');
12
+ }
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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,20 +1,28 @@
1
1
  {
2
2
  "name": "is-any-array",
3
- "version": "1.0.1",
3
+ "version": "2.0.1",
4
4
  "description": "Check if a value is any kind of array",
5
- "main": "lib/index.js",
6
- "module": "src/index.js",
5
+ "main": "./lib/index.js",
6
+ "module": "./lib-esm/index.js",
7
+ "types": "./lib/index.d.ts",
7
8
  "files": [
8
9
  "lib",
10
+ "lib-esm",
9
11
  "src"
10
12
  ],
11
13
  "scripts": {
14
+ "check-types": "tsc --noEmit",
15
+ "clean": "rimraf lib lib-esm",
12
16
  "eslint": "eslint src",
13
17
  "eslint-fix": "npm run eslint -- --fix",
14
- "prepack": "rollup -c",
15
- "test": "npm run test-coverage && npm run eslint",
16
- "test-coverage": "jest --coverage",
17
- "test-only": "jest"
18
+ "prepack": "npm run tsc",
19
+ "prettier": "prettier --check src",
20
+ "prettier-write": "prettier --write src",
21
+ "tsc": "npm run clean && npm run tsc-cjs && npm run tsc-esm",
22
+ "tsc-cjs": "tsc --project tsconfig.cjs.json",
23
+ "tsc-esm": "tsc --project tsconfig.esm.json",
24
+ "test": "npm run test-only && npm run eslint && npm run check-types",
25
+ "test-only": "jest --coverage"
18
26
  },
19
27
  "repository": {
20
28
  "type": "git",
@@ -27,22 +35,14 @@
27
35
  "url": "https://github.com/cheminfo-js/is-any-array/issues"
28
36
  },
29
37
  "homepage": "https://github.com/cheminfo-js/is-any-array#readme",
30
- "jest": {
31
- "testEnvironment": "node"
32
- },
33
38
  "devDependencies": {
34
- "@babel/plugin-transform-modules-commonjs": "^7.14.5",
35
- "cheminfo-build": "^1.1.11",
36
- "cheminfo-tools": "^1.23.3",
37
- "codecov": "^3.8.2",
38
- "eslint": "^7.29.0",
39
- "eslint-config-cheminfo": "^5.2.4",
40
- "eslint-plugin-import": "^2.23.4",
41
- "eslint-plugin-jest": "^24.3.6",
42
- "eslint-plugin-prettier": "^3.4.0",
43
- "jest": "^27.0.6",
44
- "npm-run-all": "^4.1.5",
45
- "prettier": "^2.3.2",
46
- "rollup": "^2.52.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"
47
47
  }
48
48
  }
@@ -1,4 +1,4 @@
1
- import isAnyArray from '..';
1
+ import { isAnyArray } from '..';
2
2
 
3
3
  test('isArray', () => {
4
4
  expect(isAnyArray(1)).toBe(false);
@@ -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,29 +0,0 @@
1
- # Changelog
2
-
3
- ### [1.0.1](https://www.github.com/cheminfo/is-any-array/compare/v1.0.0...v1.0.1) (2021-06-30)
4
-
5
-
6
- ### Bug Fixes
7
-
8
- * rollup in dependencies ! ([7c26c34](https://www.github.com/cheminfo/is-any-array/commit/7c26c3416287c57eaeb9fc481fb2a7b107cfa984))
9
-
10
- ## [1.0.0](https://www.github.com/cheminfo/is-any-array/compare/v0.1.1...v1.0.0) (2021-03-24)
11
-
12
-
13
- ### Bug Fixes
14
-
15
- * update readme and dependencies ([7ae8169](https://www.github.com/cheminfo/is-any-array/commit/7ae8169b1105bc9e3586f6a73315897326bb1bd4))
16
-
17
- ### [0.1.1](https://github.com/cheminfo-js/is-any-array/compare/v0.1.0...v0.1.1) (2021-02-11)
18
-
19
- # [0.1.0](https://github.com/cheminfo-js/is-any-array/compare/v0.0.3...v0.1.0) (2020-02-25)
20
-
21
-
22
-
23
- <a name="0.0.3"></a>
24
- ## [0.0.3](https://github.com/cheminfo-js/is-any-array/compare/v0.0.2...v0.0.3) (2018-10-26)
25
-
26
-
27
-
28
- <a name="0.0.2"></a>
29
- ## 0.0.2 (2018-10-26)
package/src/index.js DELETED
@@ -1,5 +0,0 @@
1
- const toString = Object.prototype.toString;
2
-
3
- export default function isAnyArray(object) {
4
- return toString.call(object).endsWith('Array]');
5
- }