Socket
Socket
Sign inDemoInstall

already

Package Overview
Dependencies
0
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.0 to 2.2.1

dist-mjs/index.d.ts

2

dist/index.d.ts

@@ -115,3 +115,3 @@ declare const _default: {

export declare function once<T, R>(fn: OnceRunnee<T, R>): OnceRunnee<T, R>;
export declare function retry<R>(times: number, fn: () => R, retryable?: (err: unknown) => boolean): R;
export declare function retry<R>(times: number, fn: () => R, retryable?: (err: Error) => boolean): R;
export interface Deferred<T> {

@@ -118,0 +118,0 @@ resolve: (t: T | PromiseLike<T>) => void;

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

export default {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deferSet = exports.OrderedAsynchrony = exports.funnel = exports.wrapFunction = exports.rethrow = exports.specific = exports.deferInspectable = exports.inspect = exports.reflect = exports.defer = exports.retry = exports.once = exports.some = exports.eachImpl = exports.each = exports.reduce = exports.map = exports.filter = exports.props = exports.tap = exports.delayChain = exports.delay = exports.concurrent = void 0;
exports.default = {
defer,

@@ -28,3 +31,3 @@ deferSet,

}
export function concurrent(size, fn) {
function concurrent(size, fn) {
const queue = makeQueue(size);

@@ -38,2 +41,3 @@ if (size < 1)

}
exports.concurrent = concurrent;
function makeQueue(size) {

@@ -70,3 +74,3 @@ const queue = {

}
export function delay(milliseconds, t) {
function delay(milliseconds, t) {
return new Promise(resolve => {

@@ -76,6 +80,8 @@ setTimeout(() => resolve(t), milliseconds);

}
export function delayChain(milliseconds) {
exports.delay = delay;
function delayChain(milliseconds) {
return tap(() => delay(milliseconds));
}
export function tap(fn) {
exports.delayChain = delayChain;
function tap(fn) {
return async (t) => {

@@ -86,3 +92,4 @@ await fn(t);

}
export function props(obj) {
exports.tap = tap;
function props(obj) {
const ret = {};

@@ -95,4 +102,5 @@ const awaiters = [];

}
exports.props = props;
const defaultFilterMapOptions = { concurrency: Infinity };
export function filter(arr, opts, filterFn) {
function filter(arr, opts, filterFn) {
if (Array.isArray(arr)) {

@@ -120,3 +128,4 @@ if (typeof opts === "function") {

}
export function map(arr, opts, mapFn) {
exports.filter = filter;
function map(arr, opts, mapFn) {
if (Array.isArray(arr)) {

@@ -144,3 +153,4 @@ if (typeof opts === "function") {

}
export function reduce(input, reducer, initialValue) {
exports.map = map;
function reduce(input, reducer, initialValue) {
if (typeof input === "function") {

@@ -155,2 +165,3 @@ initialValue = reducer;

}
exports.reduce = reduce;
async function reduceImpl(input, reducer, initialValue) {

@@ -172,3 +183,3 @@ const _input = Array.from(await input);

}
export function each(arr, eachFn) {
function each(arr, eachFn) {
if (Array.isArray(arr))

@@ -178,3 +189,4 @@ return eachImpl(eachFn)(arr);

}
export function eachImpl(eachFn) {
exports.each = each;
function eachImpl(eachFn) {
return async (arr) => {

@@ -189,3 +201,4 @@ const length = arr.length;

}
export function some(list, fn) {
exports.eachImpl = eachImpl;
function some(list, fn) {
if (typeof list === "function") {

@@ -197,2 +210,3 @@ fn = list;

}
exports.some = some;
async function someImpl(list, fn) {

@@ -207,3 +221,3 @@ const _list = toReadonlyArray(await list);

}
export function once(fn) {
function once(fn) {
if (fn) {

@@ -216,2 +230,3 @@ const _once = onceDynamic();

}
exports.once = once;
function onceDynamic() {

@@ -244,3 +259,3 @@ const state = new WeakMap();

}
export function retry(times, fn, retryable = () => true) {
function retry(times, fn, retryable = () => true) {
const retryAsync = (promise) => promise

@@ -280,3 +295,4 @@ .catch((err) => {

}
export function defer() {
exports.retry = retry;
function defer() {
var _a;

@@ -298,3 +314,4 @@ const deferred = {};

}
export function reflect(promise) {
exports.defer = defer;
function reflect(promise) {
const inspection = inspect(promise);

@@ -318,3 +335,4 @@ function handleResolution(value) {

}
export function inspect(promise) {
exports.reflect = reflect;
function inspect(promise) {
const inspectable = {

@@ -338,3 +356,4 @@ isPending: true,

}
export function deferInspectable() {
exports.inspect = inspect;
function deferInspectable() {
const deferred = defer();

@@ -365,2 +384,3 @@ const ret = {

}
exports.deferInspectable = deferInspectable;
// This logic is taken from Bluebird

@@ -393,3 +413,3 @@ function catchFilter(filters, err) {

}
export function specific(filters, handler) {
function specific(filters, handler) {
return (err) => {

@@ -401,3 +421,4 @@ if (!catchFilter(filters, err))

}
export function rethrow(fn) {
exports.specific = specific;
function rethrow(fn) {
return async (err) => {

@@ -408,3 +429,4 @@ await fn(err);

}
export function wrapFunction(wrap) {
exports.rethrow = rethrow;
function wrapFunction(wrap) {
// tslint:disable-next-line

@@ -475,3 +497,4 @@ return function (t, cb) {

}
export function funnel(opts = {}) {
exports.wrapFunction = wrapFunction;
function funnel(opts = {}) {
const { onEmpty, concurrency = 1 } = (opts || {});

@@ -564,3 +587,4 @@ let FunnelState;

}
export class OrderedAsynchrony {
exports.funnel = funnel;
class OrderedAsynchrony {
constructor() {

@@ -629,4 +653,6 @@ this.deferrals = [];

}
export function deferSet() {
exports.OrderedAsynchrony = OrderedAsynchrony;
function deferSet() {
return new OrderedAsynchrony();
}
exports.deferSet = deferSet;
{
"name": "already",
"description": "Promise extensions; map, filter, etc",
"description": "Promise extensions; finally, map, filter, etc",
"license": "MIT",
"version": "2.2.0",
"version": "2.2.1",
"author": "Gustaf Räntilä <g.rantila@gmail.com>",

@@ -11,15 +11,19 @@ "repository": {

},
"engines": {
"node": ">=12.20"
},
"type": "module",
"files": [
"dist"
"dist",
"dist-mjs"
],
"main": "./dist/index.js",
"exports": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
"import": "./dist-mjs/index.js",
"require": "./dist/index.js"
},
"scripts": {
"build:lib": "scripts/build.sh dist ./tsconfig.prod.json",
"build:test": "scripts/build.sh test-out ./tsconfig.test.json",
"build:dist": "scripts/build.sh dist ./tsconfig.prod.json --module CommonJS -t ES2019",
"build:dist-mjs": "scripts/build.sh dist-mjs ./tsconfig.prod.json --module ESNext -t ES2019",
"build:test-out": "scripts/build.sh test-out ./tsconfig.test.json",
"build:test-out-mjs": "scripts/build.sh test-out-mjs ./tsconfig.test.json --module CommonJS -t esnext && scripts/rewrite-mjs-test.js",
"build:lib": "concurrently 'yarn build:dist' 'yarn build:dist-mjs'",
"build:test": "concurrently 'yarn build:test-out' 'yarn build:test-out-mjs'",
"build": "yarn build:lib && yarn build:test",

@@ -52,7 +56,7 @@ "lint": "true",

"@babel/plugin-syntax-optional-chaining": "^7.8.3",
"@babel/plugin-transform-modules-commonjs": "^7.15.4",
"@babel/preset-typescript": "^7.15.0",
"@babel/plugin-transform-modules-commonjs": "^7.12.1",
"@babel/preset-typescript": "^7.12.7",
"@types/jest": "^26.0.15",
"commitizen": "^4.2.2",
"concurrently": "^6.2.1",
"concurrently": "^6.2.0",
"cz-conventional-changelog": "^3.3.0",

@@ -65,3 +69,3 @@ "jest": "^26.6.3",

"tslint": "6.1.3",
"typescript": "4.4.3"
"typescript": "4.3.4"
},

@@ -68,0 +72,0 @@ "dependencies": {},

@@ -14,3 +14,3 @@ [![npm version][npm-image]][npm-url]

The library is written in TypeScript, so typings are provided. It is exported only as an [ESM package](esm-package)!
The library is written in TypeScript, so typings are provided. Apart from being exported as JavaScript (ES2019), it's also exported as an *ES module*, if imported in platforms (and bundlers) supporting this.

@@ -21,3 +21,2 @@

* Since version 2, `Finally` and `Try` are removed. They should be replaced with `Promise.prototype.finally` and async functions.
* Since version 3, it's only exported as an [ESM package](esm-package).

@@ -176,7 +175,9 @@

To always delay a chain, regardless of whether it was resolved or rejected, use:
To always delay a chain, regardless of whether it was resolved or rejected, use `finallyDelay`. **Note the triple dots**, and read more about `Finally` below...
```ts
import { finallyDelay } from 'already'
somePromise
.finally( delayChain( 100 ) )
.then( ...finallyDelay( 100 ) )
```

@@ -893,2 +894,1 @@

[lgtm-url]: https://lgtm.com/projects/g/grantila/already/context:javascript
[esm-package]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc