
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Resolve a whole structure of promises
This small library is a promise-library agnostic function that resolves a whole structure or objects, arrays, promises and values to a single promise in which the whole structure is resolved.
Unlike other libraries like q-deep, resolve-deep and swear, this library is designed to work without dependencies to any promise library (and also without any other dependencies).
Note: There is no cycle check. You have to check for cycles yourself before passing the structure to the function
npm install deep-aplus
The following example demonstrates how to use this module:
import { deepAplus } from "deep-aplus";
// Create a promise that returns a value (for demonstration purposes)
function P(value) {
return new Promise((resolve) => setTimeout(() => resolve(value), 1));
}
console.log(await deepAplus(2));
// 2
console.log(await deepAplus(P(2)));
// 2
console.log(await deepAplus({ a: 1, b: P(2) }));
// { a: 1, b: 2 }
console.log(await deepAplus({ a: 1, b: [2, P(3)] }));
// { a: 1, b: [ 2, 3 ] }
console.log(await deepAplus({ a: 1, b: { c: 2, d: P(3) } }));
// { a: 1, b: { c: 2, d: 3 } }
// Nesting promises
console.log(await deepAplus({ a: 1, b: P([2, P(3)]) }));
// { a: 1, b: [ 2, 3 ] }
console.log(await deepAplus({ a: 1, b: P([2, P(3)]) }));
// { a: 1, b: [ 2, 3 ] }
console.log(await deepAplus({ a: 1, b: P({ c: 2, d: P(3) }) }));
// { a: 1, b: { c: 2, d: 3 } }
// does not dive into classes in order to preserve their functionality
class A {
a = 2;
b = P(3);
}
console.log(await deepAplus(new A()));
// A { a: 2, b: Promise { <pending> } })
deep-aplus
is published under the MIT-license.
See LICENSE.md for details.
For release notes, see CHANGELOG.md
See CONTRIBUTING.md.
Version 2.0.1 (Tue, 16 Jul 2024 23:37:18 GMT)
FAQs
Resolve a whole structure of promises
The npm package deep-aplus receives a total of 10,989 weekly downloads. As such, deep-aplus popularity was classified as popular.
We found that deep-aplus demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.