Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@thi.ng/arrays

Package Overview
Dependencies
Maintainers
1
Versions
190
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/arrays - npm Package Compare versions

Comparing version 0.7.0 to 0.8.0

12

binary-search.d.ts

@@ -1,2 +0,2 @@

import type { Comparator, Fn } from "@thi.ng/api";
import type { Comparator, Fn, FnN, FnN2 } from "@thi.ng/api";
/**

@@ -90,3 +90,3 @@ * Returns the supposed index of `x` in pre-sorted array-like collection

*/
export declare const bsLT: (i: number) => number;
export declare const bsLT: FnN;
/**

@@ -97,3 +97,3 @@ * Similar to {@link bsLT}, but for less-than-equals queries.

*/
export declare const bsLE: (i: number) => number;
export declare const bsLE: FnN;
/**

@@ -118,3 +118,3 @@ * {@link binarySearch} result index classifier for successor queries.

*/
export declare const bsGT: (i: number, n: number) => number;
export declare const bsGT: FnN2;
/**

@@ -126,3 +126,3 @@ * Similar to {@link bsGT}, but for greater-than-equals queries.

*/
export declare const bsGE: (i: number, n: number) => number;
export declare const bsGE: FnN2;
/**

@@ -134,3 +134,3 @@ * {@link binarySearch} result index classifier for equals queries.

*/
export declare const bsEQ: (i: number) => number;
export declare const bsEQ: FnN;
//# sourceMappingURL=binary-search.d.ts.map

@@ -6,2 +6,13 @@ # Change Log

# [0.8.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/arrays@0.7.0...@thi.ng/arrays@0.8.0) (2020-09-13)
### Features
* **arrays:** add first() ([3f5f722](https://github.com/thi-ng/umbrella/commit/3f5f7226e5c0495086c973a33e91fc2666f4c68c))
# [0.7.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/arrays@0.6.15...@thi.ng/arrays@0.7.0) (2020-08-28)

@@ -8,0 +19,0 @@

@@ -1,2 +0,2 @@

import { Predicate2 } from "@thi.ng/api";
import type { Predicate2 } from "@thi.ng/api";
/**

@@ -3,0 +3,0 @@ * Computes Levenshtein distance w/ optionally given `maxDist` (for

@@ -260,2 +260,3 @@ 'use strict';

const first = (buf) => buf[0];
const peek = (buf) => buf[buf.length - 1];

@@ -400,2 +401,3 @@

exports.findIndex = findIndex;
exports.first = first;
exports.fuzzyMatch = fuzzyMatch;

@@ -402,0 +404,0 @@ exports.isSorted = isSorted;

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

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@thi.ng/compare"),require("@thi.ng/equiv"),require("@thi.ng/checks"),require("@thi.ng/errors"),require("@thi.ng/api"),require("@thi.ng/random")):"function"==typeof define&&define.amd?define(["exports","@thi.ng/compare","@thi.ng/equiv","@thi.ng/checks","@thi.ng/errors","@thi.ng/api","@thi.ng/random"],r):r(((e="undefined"!=typeof globalThis?globalThis:e||self).thi=e.thi||{},e.thi.ng=e.thi.ng||{},e.thi.ng.arrays={}),e.thi.ng.compare,e.thi.ng.equiv,e.thi.ng.checks,e.thi.ng.errors,e.thi.ng.api,e.thi.ng.random)}(this,(function(e,r,t,n,i,o,u){"use strict";const s=e=>((null==e||!e[Symbol.iterator])&&i.illegalArgs("value is not iterable: "+e),e),l=(e,r,n=t.equiv)=>{for(let t=e.length;--t>=0;)if(n(r,e[t]))return t;return-1};const h=(e,r)=>e===r,a=(e,r,t=1/0,n=h)=>{if(e===r)return 0;if(e.length>r.length){const t=e;e=r,r=t}let i=e.length,o=r.length;for(;i>0&&n(e[~-i],r[~-o]);)i--,o--;let u=0;for(;u<i&&n(e[u],r[u]);)u++;if(i-=u,o-=u,0===i||o<3)return o;let s,l,a,f,c,g,d,p,y,b,m,q,v,S=0;const k=(e,r,t,i,o)=>e<r||t<r?e>t?t+1:e+1:n(o,i)?r:r+1,w=[];for(s=0;s<i;s++)w.push(s+1,e[u+s]);const A=w.length-1,T=o-3;for(;S<T;){for(b=r[u+(a=S)],m=r[u+(f=S+1)],q=r[u+(c=S+2)],v=r[u+(g=S+3)],d=S+=4,l=1/0,s=0;s<A;s+=2)p=w[s],y=w[s+1],a=k(p,a,f,b,y),f=k(a,f,c,m,y),c=k(f,c,g,q,y),d=k(c,g,d,v,y),d<l&&(l=d),w[s]=d,g=c,c=f,f=a,a=p;if(l>t)return 1/0}for(;S<o;){for(b=r[u+(a=S)],d=++S,l=1/0,s=0;s<A;s+=2)p=w[s],w[s]=d=k(p,a,d,b,w[s+1]),d<l&&(l=d),a=p;if(l>t)return 1/0}return d},f=(e,r,t)=>{const n=e[r];e[r]=e[t],e[t]=n};const c=(e,r=0,t=e.length,n=u.SYSTEM)=>{o.assert(r>=0&&t>=r&&t<=e.length,`illegal range ${r}..${t}`);let i=t-r;const s=i;if(s>1)for(;--i>=0;){const t=r+n.float(s)|0,i=r+n.float(s)|0,o=e[t];e[t]=e[i],e[i]=o}return e};e.arrayIterator=function*(e,r=0,t){if(!e)return;r=r,void 0===t&&(t=e.length);const n=r<=t?1:-1;for(;r!==t;r+=n)yield e[r]},e.binarySearch=(e,t,n=(e=>e),i=r.compare,o=0,u=e.length-1)=>{const s=n(t);for(;o<=u;){const r=o+u>>>1,t=i(n(e[r]),s);if(t<0)o=r+1;else{if(!(t>0))return r;u=r-1}}return-o-1},e.binarySearch16=(e,r)=>{let t=e[8]<=r?8:0;return t|=e[t+4]<=r?4:0,t|=e[t+2]<=r?2:0,t|=e[t+1]<=r?1:0,e[t]===r?t:-t-1},e.binarySearch32=(e,r)=>{let t=e[16]<=r?16:0;return t|=e[t+4]<=r?8:0,t|=e[t+4]<=r?4:0,t|=e[t+2]<=r?2:0,t|=e[t+1]<=r?1:0,e[t]===r?t:-t-1},e.binarySearch4=(e,r)=>{let t=e[2]<=r?2:0;return t|=e[t+1]<=r?1:0,e[t]===r?t:-t-1},e.binarySearch8=(e,r)=>{let t=e[4]<=r?4:0;return t|=e[t+2]<=r?2:0,t|=e[t+1]<=r?1:0,e[t]===r?t:-t-1},e.binarySearchNumeric=(e,t,n=r.compareNumAsc,i=0,o=e.length-1)=>{for(;i<=o;){const r=i+o>>>1,u=n(e[r],t);if(u<0)i=r+1;else{if(!(u>0))return r;o=r-1}}return-i-1},e.bsEQ=e=>e<0?-1:e,e.bsGE=(e,r)=>(e=e<0?-e-1:e)<r?e:-1,e.bsGT=(e,r)=>(e=e<0?-e-1:e+1)<r?e:-1,e.bsLE=e=>e<0?-e-2:e,e.bsLT=e=>e<0?-e-2:e-1,e.endsWith=(e,r,n=t.equiv)=>{let i=e.length,o=r.length;if(i<o)return!1;for(;--i,--o>=0&&n(e[i],r[o]););return o<0},e.ensureArray=e=>n.isArray(e)?e:[...s(e)],e.ensureArrayLike=e=>n.isArrayLike(e)?e:[...s(e)],e.ensureIterable=s,e.fillRange=(e,r=0,t=0,n=e.length,i=(n>t?1:-1))=>{if(i>0)for(;t<n;t+=i)e[r++]=t;else for(;t>n;t+=i)e[r++]=t;return e},e.find=(e,r,n=t.equiv)=>{const i=l(e,r,n);return-1!==i?e[i]:void 0},e.findIndex=l,e.fuzzyMatch=(e,r,n=t.equiv)=>{const i=e.length,o=r.length;if(o>i)return!1;if(o===i)return n(r,e);e:for(let t=0,u=0;t<o;t++){const o=r[t];for(;u<i;)if(n(e[u++],o))continue e;return!1}return!0},e.isSorted=(e,t=r.compare,n=0,i=e.length)=>{let o=e[n];for(;++n<i;){const r=e[n];if(t(o,r)>0)return!1;o=r}return!0},e.levenshtein=a,e.multiSwap=(...e)=>{const[r,t,n]=e,i=e.length;switch(i){case 0:return f;case 1:return(e,t,n)=>{f(e,t,n),f(r,t,n)};case 2:return(e,n,i)=>{f(e,n,i),f(r,n,i),f(t,n,i)};case 3:return(e,i,o)=>{f(e,i,o),f(r,i,o),f(t,i,o),f(n,i,o)};default:return(r,t,n)=>{f(r,t,n);for(let r=i;--r>=0;)f(e[r],t,n)}}},e.normalizedLevenshtein=(e,r,t=1/0,n=h)=>{const i=Math.max(e.length,r.length);return i>0?a(e,r,t,n)/i:0},e.peek=e=>e[e.length-1],e.quickSort=function e(t,n=r.compare,i=f,o=0,u=t.length-1){if(o<u){const r=t[o+(u-o>>1)];let s=o-1,l=u+1;for(;;){do{s++}while(n(t[s],r)<0);do{l--}while(n(t[l],r)>0);if(s>=l)break;i(t,s,l)}e(t,n,i,o,l),e(t,n,i,l+1,u)}return t},e.shuffle=(e,r=e.length,t=u.SYSTEM)=>c(e,0,r,t),e.shuffleRange=c,e.startsWith=(e,r,n=t.equiv)=>{let i=e.length,o=r.length;if(i<o)return!1;for(;-o>=0&&n(e[o],r[o]););return o<0},e.swap=f,e.swizzle=e=>{const[r,t,n,i,o,u,s,l]=e;switch(e.length){case 0:return()=>[];case 1:return e=>[e[r]];case 2:return e=>[e[r],e[t]];case 3:return e=>[e[r],e[t],e[n]];case 4:return e=>[e[r],e[t],e[n],e[i]];case 5:return e=>[e[r],e[t],e[n],e[i],e[o]];case 6:return e=>[e[r],e[t],e[n],e[i],e[o],e[u]];case 7:return e=>[e[r],e[t],e[n],e[i],e[o],e[u],e[s]];case 8:return e=>[e[r],e[t],e[n],e[i],e[o],e[u],e[s],e[l]];default:return r=>{const t=[];for(let n=e.length;--n>=0;)t[n]=r[e[n]];return t}}},Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@thi.ng/compare"),require("@thi.ng/equiv"),require("@thi.ng/checks"),require("@thi.ng/errors"),require("@thi.ng/api"),require("@thi.ng/random")):"function"==typeof define&&define.amd?define(["exports","@thi.ng/compare","@thi.ng/equiv","@thi.ng/checks","@thi.ng/errors","@thi.ng/api","@thi.ng/random"],r):r(((e="undefined"!=typeof globalThis?globalThis:e||self).thi=e.thi||{},e.thi.ng=e.thi.ng||{},e.thi.ng.arrays={}),e.thi.ng.compare,e.thi.ng.equiv,e.thi.ng.checks,e.thi.ng.errors,e.thi.ng.api,e.thi.ng.random)}(this,(function(e,r,t,n,i,o,u){"use strict";const s=e=>((null==e||!e[Symbol.iterator])&&i.illegalArgs("value is not iterable: "+e),e),l=(e,r,n=t.equiv)=>{for(let t=e.length;--t>=0;)if(n(r,e[t]))return t;return-1};const h=(e,r)=>e===r,a=(e,r,t=1/0,n=h)=>{if(e===r)return 0;if(e.length>r.length){const t=e;e=r,r=t}let i=e.length,o=r.length;for(;i>0&&n(e[~-i],r[~-o]);)i--,o--;let u=0;for(;u<i&&n(e[u],r[u]);)u++;if(i-=u,o-=u,0===i||o<3)return o;let s,l,a,f,c,g,d,p,y,b,m,q,v,S=0;const k=(e,r,t,i,o)=>e<r||t<r?e>t?t+1:e+1:n(o,i)?r:r+1,w=[];for(s=0;s<i;s++)w.push(s+1,e[u+s]);const A=w.length-1,T=o-3;for(;S<T;){for(b=r[u+(a=S)],m=r[u+(f=S+1)],q=r[u+(c=S+2)],v=r[u+(g=S+3)],d=S+=4,l=1/0,s=0;s<A;s+=2)p=w[s],y=w[s+1],a=k(p,a,f,b,y),f=k(a,f,c,m,y),c=k(f,c,g,q,y),d=k(c,g,d,v,y),d<l&&(l=d),w[s]=d,g=c,c=f,f=a,a=p;if(l>t)return 1/0}for(;S<o;){for(b=r[u+(a=S)],d=++S,l=1/0,s=0;s<A;s+=2)p=w[s],w[s]=d=k(p,a,d,b,w[s+1]),d<l&&(l=d),a=p;if(l>t)return 1/0}return d},f=(e,r,t)=>{const n=e[r];e[r]=e[t],e[t]=n};const c=(e,r=0,t=e.length,n=u.SYSTEM)=>{o.assert(r>=0&&t>=r&&t<=e.length,`illegal range ${r}..${t}`);let i=t-r;const s=i;if(s>1)for(;--i>=0;){const t=r+n.float(s)|0,i=r+n.float(s)|0,o=e[t];e[t]=e[i],e[i]=o}return e};e.arrayIterator=function*(e,r=0,t){if(!e)return;r=r,void 0===t&&(t=e.length);const n=r<=t?1:-1;for(;r!==t;r+=n)yield e[r]},e.binarySearch=(e,t,n=(e=>e),i=r.compare,o=0,u=e.length-1)=>{const s=n(t);for(;o<=u;){const r=o+u>>>1,t=i(n(e[r]),s);if(t<0)o=r+1;else{if(!(t>0))return r;u=r-1}}return-o-1},e.binarySearch16=(e,r)=>{let t=e[8]<=r?8:0;return t|=e[t+4]<=r?4:0,t|=e[t+2]<=r?2:0,t|=e[t+1]<=r?1:0,e[t]===r?t:-t-1},e.binarySearch32=(e,r)=>{let t=e[16]<=r?16:0;return t|=e[t+4]<=r?8:0,t|=e[t+4]<=r?4:0,t|=e[t+2]<=r?2:0,t|=e[t+1]<=r?1:0,e[t]===r?t:-t-1},e.binarySearch4=(e,r)=>{let t=e[2]<=r?2:0;return t|=e[t+1]<=r?1:0,e[t]===r?t:-t-1},e.binarySearch8=(e,r)=>{let t=e[4]<=r?4:0;return t|=e[t+2]<=r?2:0,t|=e[t+1]<=r?1:0,e[t]===r?t:-t-1},e.binarySearchNumeric=(e,t,n=r.compareNumAsc,i=0,o=e.length-1)=>{for(;i<=o;){const r=i+o>>>1,u=n(e[r],t);if(u<0)i=r+1;else{if(!(u>0))return r;o=r-1}}return-i-1},e.bsEQ=e=>e<0?-1:e,e.bsGE=(e,r)=>(e=e<0?-e-1:e)<r?e:-1,e.bsGT=(e,r)=>(e=e<0?-e-1:e+1)<r?e:-1,e.bsLE=e=>e<0?-e-2:e,e.bsLT=e=>e<0?-e-2:e-1,e.endsWith=(e,r,n=t.equiv)=>{let i=e.length,o=r.length;if(i<o)return!1;for(;--i,--o>=0&&n(e[i],r[o]););return o<0},e.ensureArray=e=>n.isArray(e)?e:[...s(e)],e.ensureArrayLike=e=>n.isArrayLike(e)?e:[...s(e)],e.ensureIterable=s,e.fillRange=(e,r=0,t=0,n=e.length,i=(n>t?1:-1))=>{if(i>0)for(;t<n;t+=i)e[r++]=t;else for(;t>n;t+=i)e[r++]=t;return e},e.find=(e,r,n=t.equiv)=>{const i=l(e,r,n);return-1!==i?e[i]:void 0},e.findIndex=l,e.first=e=>e[0],e.fuzzyMatch=(e,r,n=t.equiv)=>{const i=e.length,o=r.length;if(o>i)return!1;if(o===i)return n(r,e);e:for(let t=0,u=0;t<o;t++){const o=r[t];for(;u<i;)if(n(e[u++],o))continue e;return!1}return!0},e.isSorted=(e,t=r.compare,n=0,i=e.length)=>{let o=e[n];for(;++n<i;){const r=e[n];if(t(o,r)>0)return!1;o=r}return!0},e.levenshtein=a,e.multiSwap=(...e)=>{const[r,t,n]=e,i=e.length;switch(i){case 0:return f;case 1:return(e,t,n)=>{f(e,t,n),f(r,t,n)};case 2:return(e,n,i)=>{f(e,n,i),f(r,n,i),f(t,n,i)};case 3:return(e,i,o)=>{f(e,i,o),f(r,i,o),f(t,i,o),f(n,i,o)};default:return(r,t,n)=>{f(r,t,n);for(let r=i;--r>=0;)f(e[r],t,n)}}},e.normalizedLevenshtein=(e,r,t=1/0,n=h)=>{const i=Math.max(e.length,r.length);return i>0?a(e,r,t,n)/i:0},e.peek=e=>e[e.length-1],e.quickSort=function e(t,n=r.compare,i=f,o=0,u=t.length-1){if(o<u){const r=t[o+(u-o>>1)];let s=o-1,l=u+1;for(;;){do{s++}while(n(t[s],r)<0);do{l--}while(n(t[l],r)>0);if(s>=l)break;i(t,s,l)}e(t,n,i,o,l),e(t,n,i,l+1,u)}return t},e.shuffle=(e,r=e.length,t=u.SYSTEM)=>c(e,0,r,t),e.shuffleRange=c,e.startsWith=(e,r,n=t.equiv)=>{let i=e.length,o=r.length;if(i<o)return!1;for(;-o>=0&&n(e[o],r[o]););return o<0},e.swap=f,e.swizzle=e=>{const[r,t,n,i,o,u,s,l]=e;switch(e.length){case 0:return()=>[];case 1:return e=>[e[r]];case 2:return e=>[e[r],e[t]];case 3:return e=>[e[r],e[t],e[n]];case 4:return e=>[e[r],e[t],e[n],e[i]];case 5:return e=>[e[r],e[t],e[n],e[i],e[o]];case 6:return e=>[e[r],e[t],e[n],e[i],e[o],e[u]];case 7:return e=>[e[r],e[t],e[n],e[i],e[o],e[u],e[s]];case 8:return e=>[e[r],e[t],e[n],e[i],e[o],e[u],e[s],e[l]];default:return r=>{const t=[];for(let n=e.length;--n>=0;)t[n]=r[e[n]];return t}}},Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "@thi.ng/arrays",
"version": "0.7.0",
"version": "0.8.0",
"description": "Array / Arraylike utilities",

@@ -34,3 +34,3 @@ "module": "./index.js",

"cover": "nyc mocha test && nyc report --reporter=lcov",
"clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib",
"clean": "rimraf *.js *.d.ts *.map .nyc_output build coverage doc lib",
"doc:readme": "ts-node -P ../../tools/tsconfig.json ../../tools/src/readme.ts",

@@ -53,8 +53,8 @@ "doc": "node_modules/.bin/typedoc --mode modules --out doc --theme ../../tools/doc/typedoc-theme src",

"dependencies": {
"@thi.ng/api": "^6.12.3",
"@thi.ng/checks": "^2.7.7",
"@thi.ng/compare": "^1.3.15",
"@thi.ng/equiv": "^1.0.30",
"@thi.ng/errors": "^1.2.20",
"@thi.ng/random": "^2.0.0"
"@thi.ng/api": "^6.13.0",
"@thi.ng/checks": "^2.7.8",
"@thi.ng/compare": "^1.3.16",
"@thi.ng/equiv": "^1.0.31",
"@thi.ng/errors": "^1.2.21",
"@thi.ng/random": "^2.0.1"
},

@@ -67,6 +67,7 @@ "files": [

"keywords": [
"arrays",
"binary search",
"ES6",
"fuzzy search",
"array",
"binary",
"es6",
"fuzzy",
"search",
"shuffle",

@@ -83,3 +84,3 @@ "swizzle",

},
"gitHead": "3a55c0df86c5be9c56a1e1a4c0cfcaa2809a160a"
"gitHead": "83a0206aae59aa1b1b4bcb01c2b34bbe3db4844c"
}
/**
* Returns first element of given array or `undefined` if array is empty.
*
* @param buf - array
*/
export declare const first: <T>(buf: ArrayLike<T>) => T;
/**
* Returns last element of given array or `undefined` if array is empty.

@@ -3,0 +9,0 @@ *

/**
* Returns first element of given array or `undefined` if array is empty.
*
* @param buf - array
*/
export const first = (buf) => buf[0];
/**
* Returns last element of given array or `undefined` if array is empty.

@@ -3,0 +9,0 @@ *

@@ -43,3 +43,3 @@ <!-- This file is generated - DO NOT EDIT! -->

Package sizes (gzipped, pre-treeshake): ESM: 1.83 KB / CJS: 1.99 KB / UMD: 1.98 KB
Package sizes (gzipped, pre-treeshake): ESM: 1.84 KB / CJS: 2.00 KB / UMD: 1.99 KB

@@ -46,0 +46,0 @@ ## Dependencies

@@ -1,2 +0,2 @@

import type { IRandom } from "@thi.ng/random";
import { IRandom } from "@thi.ng/random";
import type { AnyArray } from "./api";

@@ -3,0 +3,0 @@ /**

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

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc