@cardano-sdk/util
Advanced tools
Comparing version 0.15.0 to 0.15.1
export declare const deepEquals: <T>(a: T, b: T) => boolean; | ||
export declare const strictEquals: <T>(a: T, b: T) => boolean; | ||
export declare const sameArrayItems: <T>(arrayA: T[], arrayB: T[], itemEquals: (a: T, b: T) => boolean) => boolean; | ||
export declare const areNumbersEqualInConstantTime: (a: number, b: number) => boolean; | ||
export declare const areStringsEqualInConstantTime: (a: string, b: string) => boolean; | ||
//# sourceMappingURL=equals.d.ts.map |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.sameArrayItems = exports.strictEquals = exports.deepEquals = void 0; | ||
exports.areStringsEqualInConstantTime = exports.areNumbersEqualInConstantTime = exports.sameArrayItems = exports.strictEquals = exports.deepEquals = void 0; | ||
const isEqual_1 = __importDefault(require("lodash/isEqual")); | ||
@@ -15,2 +15,11 @@ const deepEquals = (a, b) => (0, isEqual_1.default)(a, b); | ||
exports.sameArrayItems = sameArrayItems; | ||
const areNumbersEqualInConstantTime = (a, b) => (a ^ b) === 0; | ||
exports.areNumbersEqualInConstantTime = areNumbersEqualInConstantTime; | ||
const areStringsEqualInConstantTime = (a, b) => { | ||
const maxLength = Math.max(a.length, b.length); | ||
const results = Array.from({ length: maxLength }, (_, i) => (a.charCodeAt(i) === b.charCodeAt(i) ? 1 : 0)); | ||
const areAllCharactersEqual = results.reduce((accumulator, currentValue) => (accumulator & currentValue), 1); | ||
return areAllCharactersEqual === 1; | ||
}; | ||
exports.areStringsEqualInConstantTime = areStringsEqualInConstantTime; | ||
//# sourceMappingURL=equals.js.map |
export declare const deepEquals: <T>(a: T, b: T) => boolean; | ||
export declare const strictEquals: <T>(a: T, b: T) => boolean; | ||
export declare const sameArrayItems: <T>(arrayA: T[], arrayB: T[], itemEquals: (a: T, b: T) => boolean) => boolean; | ||
export declare const areNumbersEqualInConstantTime: (a: number, b: number) => boolean; | ||
export declare const areStringsEqualInConstantTime: (a: string, b: string) => boolean; | ||
//# sourceMappingURL=equals.d.ts.map |
@@ -5,2 +5,9 @@ import isEqual from 'lodash/isEqual'; | ||
export const sameArrayItems = (arrayA, arrayB, itemEquals) => arrayA.length === arrayB.length && arrayA.every((a) => arrayB.some((b) => itemEquals(a, b))); | ||
export const areNumbersEqualInConstantTime = (a, b) => (a ^ b) === 0; | ||
export const areStringsEqualInConstantTime = (a, b) => { | ||
const maxLength = Math.max(a.length, b.length); | ||
const results = Array.from({ length: maxLength }, (_, i) => (a.charCodeAt(i) === b.charCodeAt(i) ? 1 : 0)); | ||
const areAllCharactersEqual = results.reduce((accumulator, currentValue) => (accumulator & currentValue), 1); | ||
return areAllCharactersEqual === 1; | ||
}; | ||
//# sourceMappingURL=equals.js.map |
{ | ||
"name": "@cardano-sdk/util", | ||
"version": "0.15.0", | ||
"version": "0.15.1", | ||
"description": "General, not cardano-specific utils", | ||
@@ -64,3 +64,3 @@ "engines": { | ||
], | ||
"gitHead": "17887140f948a61653e01c781c7aa6e3e40d9e38" | ||
"gitHead": "68b4b7472d6058778c61a8680705211b7db6abb2" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
421284
1666