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

appolo-utils

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appolo-utils - npm Package Compare versions

Comparing version 0.0.18 to 0.0.19

24

lib/promises.js

@@ -19,2 +19,26 @@ "use strict";

}
static props(props, options = { concurrency: Infinity }) {
const keys = Object.keys(props);
const values = Object.values(props);
return Promises.map(values, (item) => item, { concurrency: options.concurrency })
.then(resolved => {
const res = {};
for (let i = 0, len = keys.length; i < len; i++) {
res[keys[i]] = resolved[i];
}
return res;
});
}
// public static propsMap<R, U>(iterable: Resolvable<Iterable<Resolvable<R>>>, mapper: (output: { [index: string]: Resolvable<U> }, item: R, index: number | string) => void, options: { concurrency: number } = {concurrency: Infinity}): Promise<{ [index: string]: U }> {
//
// let dto = {},index=0;
//
// for (let item of iterable[Symbol.iterator]()) {
// mapper(dto, item,index)
// index++;
// }
//
//
// return Promises.props(dto, {concurrency: options.concurrency})
// }
static _mapWrapper(mapper, iterator, results, params) {

@@ -21,0 +45,0 @@ let next = iterator.next();

32

lib/promises.ts

@@ -9,3 +9,3 @@ type Resolvable<R> = R | PromiseLike<R>

public static map<R, U>(iterable: Resolvable<Iterable<Resolvable<R>>>, mapper: IterateFunction<R, U>, options: { concurrency: number } = {concurrency: Infinity}) {
public static map<R, U>(iterable: Resolvable<Iterable<Resolvable<R>>>, mapper: IterateFunction<R, U>, options: { concurrency: number } = {concurrency: Infinity}): Promise<U[]> {

@@ -28,5 +28,33 @@ let concurrency = options.concurrency || Infinity;

}
public static props<T>(props: object & { [K in keyof T]: Resolvable<T[K]> }, options: { concurrency: number } = {concurrency: Infinity}): Promise<T> {
const keys = Object.keys(props);
const values = Object.values(props);
return Promises.map(values, (item) => item, {concurrency: options.concurrency})
.then(resolved => {
const res: { [K in keyof T]: T[K] } = {} as any;
for (let i = 0, len = keys.length; i < len; i++) {
res[keys[i]] = resolved[i];
}
return res
})
}
// public static propsMap<R, U>(iterable: Resolvable<Iterable<Resolvable<R>>>, mapper: (output: { [index: string]: Resolvable<U> }, item: R, index: number | string) => void, options: { concurrency: number } = {concurrency: Infinity}): Promise<{ [index: string]: U }> {
//
// let dto = {},index=0;
//
// for (let item of iterable[Symbol.iterator]()) {
// mapper(dto, item,index)
// index++;
// }
//
//
// return Promises.props(dto, {concurrency: options.concurrency})
// }
private static _mapWrapper<R, U>(mapper: IterateFunction<R, U>, iterator: IterableIterator<R>, results: any[], params: { index: number }) {

@@ -48,3 +76,3 @@

public static filter<R, U>(iterable: Resolvable<Iterable<Resolvable<R>>>, filterer: IterateFunction<R, U>, options: { concurrency: number } = {concurrency: Infinity}) {
public static filter<R, U>(iterable: Resolvable<Iterable<Resolvable<R>>>, filterer: IterateFunction<R, U>, options: { concurrency: number } = {concurrency: Infinity}): Promise<U[]> {
let concurrency = options.concurrency || Infinity;

@@ -51,0 +79,0 @@

2

package.json

@@ -17,3 +17,3 @@ {

"main": "./index.js",
"version": "0.0.18",
"version": "0.0.19",
"license": "MIT",

@@ -20,0 +20,0 @@ "repository": {

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