Socket
Socket
Sign inDemoInstall

deep-aplus

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deep-aplus - npm Package Compare versions

Comparing version 1.0.4 to 2.0.0

dist/index.d.ts

66

package.json
{
"name": "deep-aplus",
"version": "1.0.4",
"description": "Resolve a whole structure of promises, library agnostic",
"version": "2.0.0",
"description": "Resolve a whole structure of promises",
"repository": {

@@ -17,35 +17,42 @@ "type": "git",

},
"main": "index.js",
"main": "dist/index.js",
"type": "module",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"license": "MIT",
"scripts": {
"pretest": "standard --version || npm -g install standard",
"test": "mocha && standard",
"preformat": "standard --version || npm -g install standard",
"format": "standard --format",
"test:unit": "vitest --typecheck run",
"test:lint": "eslint .",
"test:build": "npm run build",
"test": "run-s test:*",
"dev:unit": "vitest --typecheck --ui",
"dev": "run-p test:*",
"build": "pkgroll",
"thought": "thought run -a",
"prethoughtcheck": "thought --version || npm -g install thought",
"thoughtcheck": "thought check-engines",
"preversion": "npm run test",
"version": "thoughtful changelog -o -a && npm run thought",
"preversion": "npm run thoughtcheck"
"prepublishOnly": "npm run build",
"postversion": "git push --tags && npm publish",
"prepare": "husky install"
},
"dependencies": {
"lodash.isplainobject": "^4.0.6"
"engines": {
"node": ">=18"
},
"devDependencies": {
"chai": "^3.2.0",
"chai-as-promised": "^5.2.0",
"mocha": "^2.2.5",
"q": "^1.4.1",
"@eslint/js": "9.7.0",
"eslint": "^8.57.0",
"globals": "^15.8.0",
"husky": "^9.0.11",
"lint-staged": "^15.2.7",
"npm-run-all": "^4.1.5",
"pkgroll": "^2.1.1",
"prettier": "^3.3.3",
"thought": "^5.0.0",
"thoughtful-release": "^0.3.0",
"trace": "^2.0.2"
"typescript": "^5.5.3",
"typescript-eslint": "^7.16.1",
"vitest": "^2.0.3"
},
"standard": {
"ignore": [
"test/fixtures/**"
]
},
"keywords": [
"promise",
"q",
"bluebird",
"a+",

@@ -57,4 +64,13 @@ "deep",

"files": [
"index.js"
"dist"
],
"lint-staged": {
"*.{js,ts}": "eslint --cache --fix",
"*.{js,css,md}": "prettier --write"
},
"funding": [
"https://www.paypal.com/donate/?hosted_button_id=GB656ZSAEQEXN",
"https://de.liberapay.com/nils.knappmeier/",
"https://github.com/sponsors/nknapp/"
]
}

@@ -1,25 +0,19 @@

# deep-aplus
# deep-aplus
[![NPM version](https://badge.fury.io/js/deep-aplus.svg)](http://badge.fury.io/js/deep-aplus)
[![Travis Build Status](https://travis-ci.org/nknapp/deep-aplus.svg?branch=master)](https://travis-ci.org/nknapp/deep-aplus)
[![Coverage Status](https://img.shields.io/coveralls/nknapp/deep-aplus.svg)](https://coveralls.io/r/nknapp/deep-aplus)
[![NPM version](https://img.shields.io/npm/v/deep-aplus.svg)](https://npmjs.com/package/deep-aplus)
[![Github Actions Status](https://github.com/nknapp/deep-aplus/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/nknapp/deep-aplus/actions/workflows/ci.yml)
> Resolve a whole structure of promises
> Resolve a whole structure of promises, library agnostic
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
or objects, arrays, promises and values to a single promise in which the whole structure is
resolved.
Unlike other libraries like [q-deep](https://npmjs.com/package/q-deep), [resolve-deep](https://npmjs.com/package/resolve-deep) and
Unlike other libraries like [q-deep](https://npmjs.com/package/q-deep), [resolve-deep](https://npmjs.com/package/resolve-deep) and
[swear](https://npmjs.com/package/swear), this library is designed to work without dependencies to any promise library
(and also without any other dependencies).
Just pass the promise constructor (i.e. `Q.Promise` or `Promise`) as first argument.
**Note: There is no cycle check. You have to check for cycles yourself before passing the
structure to the function**
structure to the function**
# Installation

@@ -36,79 +30,55 @@

```js
var Q = require('q')
var deep = require('deep-aplus')(Q.Promise)
import { deepAplus } from "../dist/index.mjs";
// Create a promise that returns a value (for demonstration purposes)
function P(value) {
return Q.delay(1).then(function () {
return value
})
return new Promise((resolve) => setTimeout(() => resolve(value), 1));
}
deep(2).then(console.log) // 2
.then(() => deep(P(2)))
.then(console.log) // 2
console.log(await deepAplus(2));
// 2
console.log(await deepAplus(P(2)));
// 2
.then(() => deep({a: 1, b: P(2)}))
.then(console.log) // { a: 1, b: 2 }
console.log(await deepAplus({ a: 1, b: P(2) }));
// { a: 1, b: 2 }
.then(() => deep({a: 1, b: [2, P(3)]}))
.then(console.log) // { a: 1, b: [ 2, 3 ] }
console.log(await deepAplus({ a: 1, b: [2, P(3)] }));
// { a: 1, b: [ 2, 3 ] }
.then(() => deep({a: 1, b: {c: 2, d: P(3)}}))
.then(console.log) // { a: 1, b: { c: 2, d: 3 } }
console.log(await deepAplus({ a: 1, b: { c: 2, d: P(3) } }));
// { a: 1, b: { c: 2, d: 3 } }
// Nesting promises
.then(() => deep({a: 1, b: P([2, P(3)])}))
.then(console.log) // { a: 1, b: [ 2, 3 ] }
// Nesting promises
console.log(await deepAplus({ a: 1, b: P([2, P(3)]) }));
// { a: 1, b: [ 2, 3 ] }
.then(() => deep({a: 1, b: P([2, P(3)])}))
.then(console.log) // { a: 1, b: [ 2, 3 ] }
console.log(await deepAplus({ a: 1, b: P([2, P(3)]) }));
// { a: 1, b: [ 2, 3 ] }
.then(() => deep({a: 1, b: P({c: 2, d: P(3)})}))
.then(console.log) // { a: 1, b: { c: 2, d: 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
.then(() => {
function A() {
this.a = 2;
this.b = P(3)
}
return deep(new A())
})
.then(console.log) // A { a: 2, b: { state: 'pending' } })
// 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> } })
```
# License
## API-reference
`deep-aplus` is published under the MIT-license.
<a name="module_index"></a>
See [LICENSE.md](LICENSE.md) for details.
### index ⇒ <code>function</code>
Creates a `deep(value)`-function using the provided constructor to
create the resulting promise and promises for intermediate steps.
The `deep` function returns a promise for the resolution of an arbitrary
structure passed as parameter
# Release-Notes
**Returns**: <code>function</code> - a function that returns a promise (of the provided class)
for a whole object structure
**Access:** public
For release notes, see [CHANGELOG.md](CHANGELOG.md)
| Param | Type | Description |
| --- | --- | --- |
| Promise | <code>function</code> | class in which promises are created |
# Contributing guidelines
## License
`deep-aplus` is published under the MIT-license.
See [LICENSE.md](LICENSE.md) for details.
## Release-Notes
For release notes, see [CHANGELOG.md](CHANGELOG.md)
## Contributing guidelines
See [CONTRIBUTING.md](CONTRIBUTING.md).
See [CONTRIBUTING.md](CONTRIBUTING.md).
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