Browse Source

[init]

tags/v0.10.0
Muthu Kumar 6 years ago
commit
a998da9810
  1. 1
      .gitignore
  2. 14
      .vscode/launch.json
  3. 1
      es6/index.js
  4. 5
      package-lock.json
  5. 15
      package.json
  6. 33
      test.js

1
.gitignore

@ -0,0 +1 @@
node_modules

14
.vscode/launch.json

@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/test.js"
}
]
}

1
es6/index.js

@ -0,0 +1 @@
module.exports = require('../index.js');

5
package-lock.json

@ -0,0 +1,5 @@
{
"name": "@codefeathers/promise.object",
"version": "0.0.1",
"lockfileVersion": 1
}

15
package.json

@ -0,0 +1,15 @@
{
"name": "@codefeathers/promise.object",
"version": "0.0.1",
"description": "Deep resolving promises in objects.",
"main": "es6/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "Muthu Kumar <@MKRhere> (https://mkr.pw)",
"contributors": [
"Thomas Rory Gummerson <@TRGWII> (https://rory.no)"
],
"license": "MIT"
}

33
test.js

@ -0,0 +1,33 @@
Promise.object = require('./es6');
const assert = require('assert');
const linked = {
foo: Promise.resolve(1),
bar: {
foobar: Promise.resolve(2)
},
baz: [1, "two", Promise.resolve(3)],
ok: "four"
}
linked.linked = linked;
Promise.object(linked).then(x => {
console.log(x);
assert(x.foo === 1);
assert(x.bar.foobar === 2);
assert(x.baz[0] === 1 && x.baz[1] === "two");
assert(Array.isArray(x.baz) && x.baz[2] === 3);
assert(x.linked === x);
});
Promise.object(
Promise.resolve({
foo: Promise.resolve({
bar: Promise.resolve(4)
})
})
).then(x => {
console.log(x)
assert(x.foo.bar === 4);
});
Loading…
Cancel
Save