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

extra-lists

Package Overview
Dependencies
Maintainers
1
Versions
150
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extra-lists - npm Package Compare versions

Comparing version 2.0.38 to 2.0.39

45

index.d.ts

@@ -14,2 +14,17 @@ declare module 'extra-lists' {

/**
* Counts values which satisfy a test.
* @param x lists
* @param fn test function (v, k, x)
* @param ths this argument
*/
export function count<T, U>(x: Lists<T, U>, fn: testFn<T, U>, ths?: object): number;
/**
* Counts occurrences of values.
* @param x lists
* @param fn map function (v, k, x)
* @param ths this argument
* @returns Map {value => count}
*/
export function countAs<T, U, V = U>(x: Lists<T, U>, fn?: mapFn<T, U, U | V>, ths?: object): Map<U | V, number>;
/**
* Lists all key-value pairs.

@@ -27,2 +42,8 @@ * @param x lists

/**
* Fills with given value.
* @param x lists
* @param v value
*/
export function fill<T, U>(x: Lists<T, U>, v: U): Lists<T, U>;
/**
* Finds first value passing a test.

@@ -48,2 +69,8 @@ * @param x lists

/**
* Gets values at keys.
* @param x lists
* @param ks keys
*/
export function getAll<T, U>(x: Lists<T, U>, ks: Iterable<T>): IterableIterator<U>;
/**
* Checks if value is lists.

@@ -104,2 +131,20 @@ * @param v value

/**
* Searches a value.
* @param x lists
* @param v search value
* @param fc compare function (a, b)
* @param fm map function (v, k, x)
* @returns key of value
*/
export function search<T, U, V = U>(x: Lists<T, U>, v: U, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): T;
/**
* Searches a value throughout.
* @param x lists
* @param v search value
* @param fc compare function (a, b)
* @param fm map function (v, k, x)
* @returns keys of value
*/
export function searchAll<T, U, V = U>(x: Lists<T, U>, v: U, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): IterableIterator<T>;
/**
* Gets size of part of lists.

@@ -106,0 +151,0 @@ * @param x lists

@@ -59,2 +59,27 @@ 'use strict';

function count(x, fn, ths = null) {
var [ks, vs] = x, ki = ks[Symbol.iterator](), a = 0;
for (var v of vs) {
var k = ki.next().value;
if (fn.call(ths, v, k, x))
a++;
}
return a;
}
function id$1(v) {
return v;
}
function countAs(x, fn = null, ths = null) {
var fn = fn || id$1;
var [ks, vs] = x, ki = ks[Symbol.iterator](), a = new Map();
for (var v of vs) {
var k = ki.next().value;
var v1 = fn.call(ths, v, k, x);
a.set(v1, (a.get(v1) || 0) + 1);
}
return a;
}
function* entries(x) {

@@ -90,2 +115,8 @@ var [ks, vs] = x, ki = ks[Symbol.iterator]();

function fill(x, v) {
var ks = Array.from(x[0]);
var vs = Array.from(x[1]).map(_ => v);
return [ks, vs];
}
function find(x, fn, ths = null) {

@@ -117,2 +148,24 @@ var [ks, vs] = x, ki = ks[Symbol.iterator]();

function* getAll(x, ks) {
var [js, vs] = x, m = new Map();
var ji = js[Symbol.iterator]();
var ki = ks[Symbol.iterator]();
var { value, done } = ki.next();
if (done)
return;
for (var v of vs) {
var j = ji.next().value;
m.set(j, v);
}
}
function is$1(v) {

@@ -179,2 +232,30 @@ return Array.isArray(v) && v.length === 2 && isList(v[0]) && isList(v[1]);

function cmp$1(a, b) {
return a < b ? -1 : (a > b ? 1 : 0);
}
function search(x, v, fc = null, fm = null) {
var fc = fc || cmp$1, fm = fm || id$1;
var [ks, vs] = x, ki = ks[Symbol.iterator]();
var v1 = fm(v, null, null);
for (var u of vs) {
var k = ki.next().value;
var u1 = fm(u, k, x);
if (fc(u1, v1) === 0)
return k;
}
}
function* searchAll(x, v, fc = null, fm = null) {
var fc = fc || cmp$1, fm = fm || id$1;
var [ks, vs] = x, ki = ks[Symbol.iterator]();
var v1 = fm(v, null, null);
for (var u of vs) {
var k = ki.next().value;
var u1 = fm(u, k, x);
if (fc(u1, v1) === 0)
yield k;
}
}
function someIf(x) {

@@ -207,7 +288,11 @@ for (var v of x[1])

exports.concat = concat$1;
exports.count = count;
exports.countAs = countAs;
exports.entries = entries;
exports.every = every;
exports.fill = fill;
exports.find = find;
exports.forEach = forEach;
exports.get = get;
exports.getAll = getAll;
exports.is = is$1;

@@ -222,4 +307,6 @@ exports.isMany = isMany;

exports.reduce = reduce;
exports.search = search;
exports.searchAll = searchAll;
exports.size = size$1;
exports.some = some;
exports.values = values;

2

package.json
{
"name": "extra-lists",
"version": "2.0.38",
"version": "2.0.39",
"description": "Lists is pair of list of keys, and values.",

@@ -5,0 +5,0 @@ "main": "index.js",

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