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

iterable-operator

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iterable-operator - npm Package Compare versions

Comparing version 0.1.0 to 0.2.1

lib/iterable-operator.d.ts

1

lib/index.d.ts

@@ -5,1 +5,2 @@ export * from './$';

export * from './pipe-tail';
export * from './iterable-operator';

@@ -10,2 +10,3 @@ "use strict";

__export(require("./pipe-tail"));
__export(require("./iterable-operator"));
//# sourceMappingURL=index.js.map

5

lib/pipe-head/range.d.ts

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

export declare function range(): Iterable<number>;
export declare function range(start: number): Iterable<number>;
export declare function range(end: number): Iterable<number>;
export declare function range(start: number, end: number): Iterable<number>;
export declare function range(start: number, end: number, step: number): Iterable<number>;
export declare function range(start: number, end: number, unsignedStep: number): Iterable<number>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function range(start = Number.MIN_SAFE_INTEGER, end = Number.MAX_SAFE_INTEGER + 1, step = 1) {
function* rangeUnsignedStep(start, end, step) {
if (start < end) {
for (let i = start; i < end; i += step)
yield i;
}
else {
for (let i = start; i > end; i -= step)
yield i;
}
}
function range(startOrEnd, end, step = 1) {
if (arguments.length === 1) {
const end = startOrEnd;
return rangeUnsignedStep(0, end, 1);
}
if (step < 0)
throw new RangeError('Invalid step value');
return (function* () {
if (start < end) {
for (let i = start; i < end; i += step)
yield i;
}
else {
for (let i = start; i > end; i -= step)
yield i;
}
})();
const start = startOrEnd;
return rangeUnsignedStep(start, end, step);
}
exports.range = range;
//# sourceMappingURL=range.js.map
export declare function done<T>(iterable: Iterable<T>): T[];
export declare function done<T, U extends (iterable: Iterable<T>) => any>(iterable: Iterable<T>, factory: U): ReturnType<U>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function done(iterable) {
return [...iterable];
function done(iterable, factory = (iterable) => Array.from(iterable)) {
return factory(iterable);
}
exports.done = done;
//# sourceMappingURL=done.js.map

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

export declare function includes<T>(iterable: Iterable<T>, sequence: T[]): boolean;
export declare function includes<T>(iterable: Iterable<T>, sequence: ArrayLike<T>): boolean;

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

export declare function run(...iterables: Iterable<unknown>[]): void;
export declare function run(iterable: Iterable<unknown>): void;
export declare function run<T>(iterable: Iterable<T>, fn: (element: T, index: number) => void): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function run(...iterables) {
iterables.forEach(iterable => {
const iterator = iterable[Symbol.iterator]();
function run(iterable, fn) {
const iterator = iterable[Symbol.iterator]();
if (fn) {
let result, index = 0;
while (result = iterator.next(), !result.done)
fn(result.value, index++);
}
else {
while (!iterator.next().done) { }
});
}
}
exports.run = run;
//# sourceMappingURL=run.js.map

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

export declare function concat<T>(iterable: Iterable<T>): Iterable<T>;
export declare function concat(): never;
export declare function concat<T>(iterable: Iterable<T>): never;
export declare function concat<T1, T2>(iterable1: Iterable<T1>, iterable2: Iterable<T2>): Iterable<T1 | T2>;

@@ -3,0 +4,0 @@ export declare function concat<T1, T2, T3>(iterable1: Iterable<T1>, iterable2: Iterable<T2>, iterable3: Iterable<T3>): Iterable<T1 | T2 | T3>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function* concat(...iterables) {
for (const iterable of iterables) {
yield* iterable;
}
function concat(...iterables) {
if (iterables.length < 2)
throw new TypeError(`At least 2 argument required, but only ${iterables.length} present.`);
return (function* () {
for (const iterable of iterables) {
yield* iterable;
}
})();
}
exports.concat = concat;
//# sourceMappingURL=concat.js.map

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

export declare function each<T>(iterable: Iterable<T>, fn: (element: T, index: number) => void): Generator<T, void, unknown>;
export declare function each<T>(iterable: Iterable<T>, fn: (element: T, index: number) => void): Iterable<T>;

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

export declare function filter<T>(iterable: Iterable<T>, fn: (element: T, index: number) => boolean): Generator<T, void, unknown>;
export declare function filter<T>(iterable: Iterable<T>, fn: (element: T, index: number) => boolean): Iterable<T>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function isChar(obj) {
return typeof obj === 'string' && obj.length === 1;
}
function isIterable(obj) {
return typeof obj[Symbol.iterator] === 'function';
}
function flatten(iterable, depth = Infinity) {

@@ -8,3 +14,3 @@ if (depth < 0)

for (const element of iterable) {
if (depth > 0 && element[Symbol.iterator]) {
if (depth > 0 && isIterable(element) && !isChar(element)) {
yield* flatten(element, depth - 1);

@@ -11,0 +17,0 @@ }

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

export declare function map<T, U>(iterable: Iterable<T>, fn: (element: T, index: number) => U): Generator<U, void, unknown>;
export declare function map<T, U>(iterable: Iterable<T>, fn: (element: T, index: number) => U): Iterable<U>;
{
"name": "iterable-operator",
"version": "0.1.0",
"version": "0.2.1",
"description": "Minimalist utility for JavaScript Iterable.",

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

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

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