@atlaspack/utils
Advanced tools
Comparing version 2.12.1-dev.3520 to 2.12.1-dev.3565
{ | ||
"name": "@atlaspack/utils", | ||
"version": "2.12.1-dev.3520+8a5346e28", | ||
"version": "2.12.1-dev.3565+b31bc6b33", | ||
"description": "Blazing fast, zero configuration web application bundler", | ||
@@ -32,7 +32,7 @@ "license": "(MIT OR Apache-2.0)", | ||
"dependencies": { | ||
"@atlaspack/codeframe": "2.12.1-dev.3520+8a5346e28", | ||
"@atlaspack/diagnostic": "2.12.1-dev.3520+8a5346e28", | ||
"@atlaspack/logger": "2.12.1-dev.3520+8a5346e28", | ||
"@atlaspack/markdown-ansi": "2.12.1-dev.3520+8a5346e28", | ||
"@atlaspack/rust": "2.12.1-dev.3520+8a5346e28", | ||
"@atlaspack/codeframe": "2.12.1-dev.3565+b31bc6b33", | ||
"@atlaspack/diagnostic": "2.12.1-dev.3565+b31bc6b33", | ||
"@atlaspack/logger": "2.12.1-dev.3565+b31bc6b33", | ||
"@atlaspack/markdown-ansi": "2.12.1-dev.3565+b31bc6b33", | ||
"@atlaspack/rust": "2.12.1-dev.3565+b31bc6b33", | ||
"@parcel/source-map": "^2.1.1", | ||
@@ -67,3 +67,3 @@ "chalk": "^4.1.0", | ||
}, | ||
"gitHead": "8a5346e28c1bb3b9cd40f1c4e77c66dd6666f1e4" | ||
"gitHead": "b31bc6b33de40c158b9f4d8ff177238be0de409d" | ||
} |
@@ -37,2 +37,12 @@ // @flow strict-local | ||
/** | ||
* Get the difference of A and B sets | ||
* | ||
* This is the set of elements which are in A but not in B | ||
* For example, the difference of the sets {1,2,3} and {3,4} is {1,2} | ||
* | ||
* @param {*} a Set A | ||
* @param {*} b Set B | ||
* @returns A \ B | ||
*/ | ||
export function setDifference<T>( | ||
@@ -48,2 +58,26 @@ a: $ReadOnlySet<T>, | ||
} | ||
return difference; | ||
} | ||
/** | ||
* Get the symmetric difference of A and B sets | ||
* | ||
* This is the set of elements which are in either of the sets, but not in their intersection. | ||
* For example, the symmetric difference of the sets {1,2,3} and {3,4} is {1,2,4} | ||
* | ||
* @param {*} a Set A | ||
* @param {*} b Set B | ||
* @returns A Δ B | ||
*/ | ||
export function setSymmetricDifference<T>( | ||
a: $ReadOnlySet<T>, | ||
b: $ReadOnlySet<T>, | ||
): Set<T> { | ||
let difference = new Set(); | ||
for (let e of a) { | ||
if (!b.has(e)) { | ||
difference.add(e); | ||
} | ||
} | ||
for (let d of b) { | ||
@@ -50,0 +84,0 @@ if (!a.has(d)) { |
@@ -39,2 +39,3 @@ // @flow strict-local | ||
setDifference, | ||
setSymmetricDifference, | ||
setEqual, | ||
@@ -41,0 +42,0 @@ setIntersect, |
@@ -8,2 +8,3 @@ // @flow | ||
setDifference, | ||
setSymmetricDifference, | ||
} from '../src/collection'; | ||
@@ -46,2 +47,3 @@ | ||
}); | ||
describe('setDifference', () => { | ||
@@ -51,2 +53,11 @@ it('returns a setDifference of two sets of T type', () => { | ||
setDifference(new Set([1, 2, 3]), new Set([3, 4, 5])), | ||
new Set([1, 2]), | ||
); | ||
}); | ||
}); | ||
describe('setSymmetricDifference', () => { | ||
it('returns a setSymmetricDifference of two sets of T type', () => { | ||
assert.deepEqual( | ||
setSymmetricDifference(new Set([1, 2, 3]), new Set([3, 4, 5])), | ||
new Set([1, 2, 4, 5]), | ||
@@ -53,0 +64,0 @@ ); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
3624377
40110