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

@azure-tools/linq

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azure-tools/linq - npm Package Compare versions

Comparing version 3.0.116 to 3.0.117

15

dist/main.d.ts

@@ -15,3 +15,3 @@ export * from './freeze';

linq: {
any(predicate: (each: T) => boolean): boolean;
any(predicate?: (each: T) => boolean): boolean;
all(predicate: (each: T) => boolean): boolean;

@@ -25,2 +25,4 @@ bifurcate(predicate: (each: T) => boolean): Array<Array<T>>;

where(predicate: (each: T) => boolean): Linqable<T>;
forEach(action: (each: T) => void): void;
aggregate<A, R>(accumulator: (current: T | A, next: T) => A, seed?: T | A, resultAction?: (result?: T | A) => A | R): T | A | R | undefined;
toArray(): Array<T>;

@@ -30,7 +32,7 @@ };

/** returns an Linqable<> for keys in the collection */
export declare function keys<K, T, TSrc extends (Array<T> | Dictionary<T> | Map<K, T>)>(source: TSrc & (Array<T> | Dictionary<T> | Map<K, T>)): Linqable<IndexOf<TSrc>>;
export declare function keys<K, T, TSrc extends (Array<T> | Dictionary<T> | Map<K, T>)>(source: (TSrc & (Array<T> | Dictionary<T> | Map<K, T>)) | null | undefined): Linqable<IndexOf<TSrc>>;
/** returns an Linqable<> for values in the collection */
export declare function values<K, T, TSrc extends (Array<T> | Dictionary<T> | Map<K, T>)>(source: (Array<T> | Dictionary<T> | Map<K, T>)): Linqable<T>;
export declare function values<K, T, TSrc extends (Array<T> | Dictionary<T> | Map<K, T>)>(source: (Iterable<T> | Array<T> | Dictionary<T> | Map<K, T>) | null | undefined): Linqable<T>;
/** returns an Linqable<{key,value}> for the Collection */
export declare function items<K, T, TSrc extends (Array<T> | Dictionary<T> | Map<K, T>)>(source: TSrc & (Array<T> | Dictionary<T> | Map<K, T>)): Linqable<{
export declare function items<K, T, TSrc extends (Array<T> | Dictionary<T> | Map<K, T>)>(source: (TSrc & (Array<T> | Dictionary<T> | Map<K, T>)) | null | undefined): Linqable<{
key: IndexOf<TSrc>;

@@ -40,7 +42,10 @@ value: T;

export declare function length<T, K>(source?: Dictionary<T> | Array<T> | Map<K, T>): number;
export declare function any<T>(this: Iterable<T>, predicate: (each: T) => boolean): boolean;
export declare function any<T>(this: Iterable<T>, predicate?: (each: T) => boolean): boolean;
export declare function all<T>(this: Iterable<T>, predicate: (each: T) => boolean): boolean;
export declare function concat<T>(this: Iterable<T>, more: Iterable<T>): Linqable<T>;
export declare function select<T, V>(this: Iterable<T>, selector: (each: T) => V): Linqable<V>;
export declare function selectMany<T, V>(this: Iterable<T>, selector: (each: T) => Iterable<V>): Linqable<V>;
export declare function where<T>(this: Iterable<T>, predicate: (each: T) => boolean): Linqable<T>;
export declare function forEach<T>(this: Iterable<T>, action: (each: T) => void): void;
export declare function aggregate<T, A, R>(this: Iterable<T>, accumulator: (current: T | A, next: T) => A, seed?: T | A, resultAction?: (result?: T | A) => A | R): T | A | R | undefined;
export declare function selectNonNullable<T, V>(this: Iterable<T>, selector: (each: T) => V): Linqable<NonNullable<V>>;

@@ -47,0 +52,0 @@ export declare function nonNullable<T>(this: Iterable<T>): Linqable<NonNullable<T>>;

@@ -22,2 +22,5 @@ "use strict";

function linqify(iterable) {
if (!!iterable['linq']) {
return iterable;
}
return Object.defineProperty(iterable, 'linq', {

@@ -37,2 +40,4 @@ get: () => {

where: where.bind(iterable),
forEach: forEach.bind(iterable),
aggregate: aggregate.bind(iterable),
};

@@ -44,25 +49,30 @@ }

function keys(source) {
if (Array.isArray(source)) {
return linqify(source.keys());
}
if (source instanceof Map) {
return linqify(source.keys());
}
if (source) {
if (Array.isArray(source)) {
return linqify(source.keys());
}
if (source instanceof Map) {
return linqify(source.keys());
}
return linqify((Object.getOwnPropertyNames(source)));
}
// undefined/null
return linqify([]);
}
exports.keys = keys;
function isIterable(source) {
return !!source && !!source[Symbol.iterator];
}
/** returns an Linqable<> for values in the collection */
function values(source) {
if (Array.isArray(source)) {
return linqify(function* () { for (const v of source) {
yield v;
} }());
}
if (source instanceof Map) {
return linqify(source.values());
}
if (source) {
// map
if (source instanceof Map) {
return linqify(source.values());
}
// any iterable source
if (isIterable(source)) {
return linqify(source);
}
// dictionary (object keys)
return linqify(function* () {

@@ -77,2 +87,3 @@ for (const key of keys(source)) {

}
// null/undefined
return linqify([]);

@@ -83,13 +94,13 @@ }

function items(source) {
if (Array.isArray(source)) {
return linqify(function* () { for (let i = 0; i < source.length; i++) {
yield { key: i, value: source[i] };
} }());
}
if (source instanceof Map) {
return linqify(function* () { for (const [key, value] of source.entries()) {
yield { key, value };
} }());
}
if (source) {
if (Array.isArray(source)) {
return linqify(function* () { for (let i = 0; i < source.length; i++) {
yield { key: i, value: source[i] };
} }());
}
if (source instanceof Map) {
return linqify(function* () { for (const [key, value] of source.entries()) {
yield { key, value };
} }());
}
return linqify(function* () {

@@ -106,2 +117,3 @@ for (const key of keys(source)) {

}
// undefined/null
return linqify([]);

@@ -125,3 +137,3 @@ }

for (const each of this) {
if (predicate(each)) {
if (!predicate || predicate(each)) {
return true;

@@ -142,2 +154,13 @@ }

exports.all = all;
function concat(more) {
return linqify(function* () {
for (const each of this) {
yield each;
}
for (const each of more) {
yield each;
}
}.bind(this)());
}
exports.concat = concat;
function select(selector) {

@@ -171,2 +194,20 @@ return linqify(function* () {

exports.where = where;
function forEach(action) {
for (const each of this) {
action(each);
}
}
exports.forEach = forEach;
function aggregate(accumulator, seed, resultAction) {
let result = seed;
for (const each of this) {
if (result === undefined) {
result = each;
continue;
}
result = accumulator(result, each);
}
return resultAction !== undefined ? resultAction(result) : result;
}
exports.aggregate = aggregate;
function selectNonNullable(selector) {

@@ -173,0 +214,0 @@ return linqify(function* () {

{
"name": "@azure-tools/linq",
"version": "3.0.116",
"version": "3.0.117",
"description": "LINQ-like functionality for Typescript.",

@@ -5,0 +5,0 @@ "main": "./dist/main.js",

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