Socket
Socket
Sign inDemoInstall

@cosmjs/utils

Package Overview
Dependencies
Maintainers
2
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cosmjs/utils - npm Package Compare versions

Comparing version 0.25.0-alpha.0 to 0.25.0-alpha.1

25

build/array.spec.js

@@ -30,3 +30,28 @@ "use strict";

});
describe("arrayContentStartsWith", () => {
it("can compare number arrays", () => {
// same length
expect(arrays_1.arrayContentStartsWith([], [])).toEqual(true); // Same behaviour as "".startsWith("")
expect(arrays_1.arrayContentStartsWith([1, 2, 3], [1, 2, 3])).toEqual(true);
expect(arrays_1.arrayContentStartsWith([1, 2, 3], [1, 2, 8])).toEqual(false);
expect(arrays_1.arrayContentStartsWith([1, 2, 3], [0, 0, 0])).toEqual(false);
// a shorter than b
expect(arrays_1.arrayContentStartsWith([], [1, 2, 3])).toEqual(false);
expect(arrays_1.arrayContentStartsWith([1], [1, 2, 3])).toEqual(false);
expect(arrays_1.arrayContentStartsWith([1, 2], [1, 2, 3])).toEqual(false);
// a longer than b
expect(arrays_1.arrayContentStartsWith([1, 2, 3, 4, 5], [1, 2, 3, 4, 5])).toEqual(true);
expect(arrays_1.arrayContentStartsWith([1, 2, 3, 4, 5], [1, 2, 3, 4])).toEqual(true);
expect(arrays_1.arrayContentStartsWith([1, 2, 3, 4, 5], [1, 2, 3])).toEqual(true);
expect(arrays_1.arrayContentStartsWith([1, 2, 3, 4, 5], [1, 2])).toEqual(true);
expect(arrays_1.arrayContentStartsWith([1, 2, 3, 4, 5], [1])).toEqual(true);
expect(arrays_1.arrayContentStartsWith([1, 2, 3, 4, 5], [])).toEqual(true);
expect(arrays_1.arrayContentStartsWith([1, 2, 3, 4, 5], [1, 2, 3, 4, 0])).toEqual(false);
expect(arrays_1.arrayContentStartsWith([1, 2, 3, 4, 5], [1, 2, 3, 0])).toEqual(false);
expect(arrays_1.arrayContentStartsWith([1, 2, 3, 4, 5], [1, 2, 0])).toEqual(false);
expect(arrays_1.arrayContentStartsWith([1, 2, 3, 4, 5], [1, 0])).toEqual(false);
expect(arrays_1.arrayContentStartsWith([1, 2, 3, 4, 5], [0])).toEqual(false);
});
});
});
//# sourceMappingURL=array.spec.js.map

@@ -10,1 +10,10 @@ /**

export declare function arrayContentEquals<T extends string | number | boolean>(a: ArrayLike<T>, b: ArrayLike<T>): boolean;
/**
* Checks if `a` starts with the contents of `b`.
*
* This requires equality of the element values, where element equality means `===` returning `true`.
*
* This allows you to compare the content of a Buffer, Uint8Array or number[], ignoring the specific type.
* As a consequence, this returns different results than Jasmine's `toEqual`, which ensures elements have the same type.
*/
export declare function arrayContentStartsWith<T extends string | number | boolean>(a: ArrayLike<T>, b: ArrayLike<T>): boolean;

20

build/arrays.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.arrayContentEquals = void 0;
exports.arrayContentStartsWith = exports.arrayContentEquals = void 0;
/**

@@ -22,2 +22,20 @@ * Compares the content of two arrays-like objects for equality.

exports.arrayContentEquals = arrayContentEquals;
/**
* Checks if `a` starts with the contents of `b`.
*
* This requires equality of the element values, where element equality means `===` returning `true`.
*
* This allows you to compare the content of a Buffer, Uint8Array or number[], ignoring the specific type.
* As a consequence, this returns different results than Jasmine's `toEqual`, which ensures elements have the same type.
*/
function arrayContentStartsWith(a, b) {
if (a.length < b.length)
return false;
for (let i = 0; i < b.length; ++i) {
if (a[i] !== b[i])
return false;
}
return true;
}
exports.arrayContentStartsWith = arrayContentStartsWith;
//# sourceMappingURL=arrays.js.map

2

build/index.d.ts

@@ -1,4 +0,4 @@

export { arrayContentEquals } from "./arrays";
export { arrayContentEquals, arrayContentStartsWith } from "./arrays";
export { assert, assertDefined, assertDefinedAndNotNull } from "./assert";
export { sleep } from "./sleep";
export { isNonNullObject, isUint8Array } from "./typechecks";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isUint8Array = exports.isNonNullObject = exports.sleep = exports.assertDefinedAndNotNull = exports.assertDefined = exports.assert = exports.arrayContentEquals = void 0;
exports.isUint8Array = exports.isNonNullObject = exports.sleep = exports.assertDefinedAndNotNull = exports.assertDefined = exports.assert = exports.arrayContentStartsWith = exports.arrayContentEquals = void 0;
var arrays_1 = require("./arrays");
Object.defineProperty(exports, "arrayContentEquals", { enumerable: true, get: function () { return arrays_1.arrayContentEquals; } });
Object.defineProperty(exports, "arrayContentStartsWith", { enumerable: true, get: function () { return arrays_1.arrayContentStartsWith; } });
var assert_1 = require("./assert");

@@ -7,0 +8,0 @@ Object.defineProperty(exports, "assert", { enumerable: true, get: function () { return assert_1.assert; } });

{
"name": "@cosmjs/utils",
"version": "0.25.0-alpha.0",
"version": "0.25.0-alpha.1",
"description": "Utility tools, primarily for testing code",

@@ -42,3 +42,3 @@ "contributors": [

},
"gitHead": "171fda884c953fb06327d42535ebf6958e66e45a"
"gitHead": "906b259dd0b179e7acd7b05b22f7671e87d77796"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc