@douglasneuroinformatics/libjs 0.1.0 → 0.2.0
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/dist/array.d.ts +9 -0
- package/dist/array.d.ts.map +1 -0
- package/dist/array.js +12 -0
- package/dist/array.test.d.ts +2 -0
- package/dist/array.test.d.ts.map +1 -0
- package/dist/array.test.js +24 -0
- package/dist/douglasneuroinformatics-libjs-0.2.0.tgz +0 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +1 -1
- package/dist/douglasneuroinformatics-libjs-0.1.0.tgz +0 -0
package/dist/array.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return whether all items in the array are unique
|
|
3
|
+
*/
|
|
4
|
+
export declare function isUnique(arr: unknown[]): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Return whether the array contains duplicate values
|
|
7
|
+
*/
|
|
8
|
+
export declare function hasDuplicates(arr: unknown[]): boolean;
|
|
9
|
+
//# sourceMappingURL=array.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../src/array.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,WAEtC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,WAE3C"}
|
package/dist/array.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return whether all items in the array are unique
|
|
3
|
+
*/
|
|
4
|
+
export function isUnique(arr) {
|
|
5
|
+
return new Set(arr).size === arr.length;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Return whether the array contains duplicate values
|
|
9
|
+
*/
|
|
10
|
+
export function hasDuplicates(arr) {
|
|
11
|
+
return !isUnique(arr);
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.test.d.ts","sourceRoot":"","sources":["../src/array.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { hasDuplicates, isUnique } from './array.js';
|
|
3
|
+
describe('isUnique', () => {
|
|
4
|
+
it('should return true for a unique array', () => {
|
|
5
|
+
expect(isUnique([1, 2, 3])).toBe(true);
|
|
6
|
+
});
|
|
7
|
+
it('should return true for an empty array', () => {
|
|
8
|
+
expect(isUnique([])).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
it('should return false for an array with duplicate values', () => {
|
|
11
|
+
expect(isUnique([1, 2, 2])).toBe(false);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
describe('hasDuplicates', () => {
|
|
15
|
+
it('should return false for a unique array', () => {
|
|
16
|
+
expect(hasDuplicates([1, 2, 3])).toBe(false);
|
|
17
|
+
});
|
|
18
|
+
it('should return false for an empty array', () => {
|
|
19
|
+
expect(hasDuplicates([])).toBe(false);
|
|
20
|
+
});
|
|
21
|
+
it('should return true for an array with duplicate values', () => {
|
|
22
|
+
expect(hasDuplicates([1, 2, 2])).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
Binary file
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
Binary file
|