Skip to content
This repository was archived by the owner on Sep 16, 2020. It is now read-only.

Commit b45c52f

Browse files
author
crossjs
committed
0.0.1
0 parents  commit b45c52f

21 files changed

+1359
-0
lines changed

.babelrc

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"env": {
3+
"development": {
4+
"presets": ["es2015", "stage-0"],
5+
"plugins": [
6+
"add-module-exports",
7+
["__coverage__", { "ignore": "test/" }],
8+
"transform-runtime"
9+
]
10+
},
11+
"production": {
12+
"presets": ["es2015-rollup", "stage-0"]
13+
}
14+
}
15+
}

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.eslintignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
coverage
2+
dist
3+
node_modules
4+
5+
index.js
6+
index.min.js

.eslintrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"root": true,
3+
"extends": [
4+
"plato"
5+
]
6+
}

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_STORE
2+
*.bak
3+
*.log
4+
*.old
5+
*.out
6+
7+
coverage
8+
dist
9+
node_modules

.npmignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.DS_STORE
2+
*.bak
3+
*.log
4+
*.old
5+
*.out
6+
7+
.tools
8+
coverage
9+
node_modules
10+
test

.tools/build.js

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
process.env.BABEL_ENV = 'production'
2+
3+
var fs = require('fs')
4+
var rollup = require('rollup')
5+
var uglify = require('uglify-js')
6+
var nodeResolve = require('rollup-plugin-node-resolve')
7+
var buble = require('rollup-plugin-buble')
8+
var version = process.env.VERSION || require('../package.json').version
9+
10+
var banner =
11+
'/*!\n' +
12+
' * NUO v' + version + '\n' +
13+
' * (c) ' + new Date().getFullYear() + ' crossjs\n' +
14+
' * Released under the MIT License.\n' +
15+
' */'
16+
17+
// cjs
18+
rollup.rollup({
19+
entry: 'src/index.js',
20+
plugins: [
21+
buble()
22+
]
23+
})
24+
.then(function (bundle) {
25+
var code = bundle.generate({
26+
format: 'cjs',
27+
banner
28+
}).code
29+
return write('dist/index.js', code).then(function () {
30+
return code
31+
})
32+
})
33+
.then(function (code) {
34+
var minified = banner + '\n' + uglify.minify(code, {
35+
fromString: true,
36+
output: {
37+
ascii_only: true
38+
}
39+
}).code
40+
return write('dist/index.min.js', minified)
41+
})
42+
.catch(logError)
43+
44+
// iife
45+
rollup.rollup({
46+
entry: 'src/index.js',
47+
plugins: [
48+
nodeResolve({
49+
jsnext: true,
50+
browser: true
51+
}),
52+
buble()
53+
]
54+
})
55+
.then(function (bundle) {
56+
var code = bundle.generate({
57+
format: 'iife',
58+
moduleName: 'nuo',
59+
banner
60+
}).code
61+
return write('index.js', code).then(function () {
62+
return code
63+
})
64+
})
65+
.then(function (code) {
66+
var minified = banner + '\n' + uglify.minify(code, {
67+
fromString: true,
68+
output: {
69+
ascii_only: true
70+
}
71+
}).code
72+
return write('index.min.js', minified)
73+
})
74+
.catch(logError)
75+
76+
function write (dest, code) {
77+
return new Promise(function (resolve, reject) {
78+
fs.writeFile(dest, code, function (err) {
79+
if (err) return reject(err)
80+
console.log(blue(dest) + ' ' + getSize(code))
81+
resolve()
82+
})
83+
})
84+
}
85+
86+
function getSize (code) {
87+
return (code.length / 1024).toFixed(2) + 'kb'
88+
}
89+
90+
function logError (e) {
91+
console.log(e)
92+
}
93+
94+
function blue (str) {
95+
return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m'
96+
}

.tools/release.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
set -e
2+
echo "Enter release version: "
3+
read VERSION
4+
5+
read -p "Releasing $VERSION - are you sure? (y/n)" -n 1 -r
6+
echo # (optional) move to a new line
7+
if [[ $REPLY =~ ^[Yy]$ ]]
8+
then
9+
echo "Releasing $VERSION ..."
10+
11+
# test
12+
npm run lint
13+
14+
# test
15+
npm run test
16+
17+
# build
18+
rm -rf dist
19+
mkdir dist
20+
npm run build
21+
22+
# commit
23+
git add -A
24+
git commit -m "* :tada: build $VERSION"
25+
npm version $VERSION --message "* :bookmark: bump $VERSION"
26+
27+
# publish
28+
git push
29+
npm publish
30+
fi

.travis.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
language: node_js
2+
3+
node_js:
4+
- "5"
5+
6+
after_success:
7+
- npm run coverage
8+
- npm i coveralls
9+
- cat ./coverage/*/lcov.info | coveralls

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright (c) 2016 crossjs
2+
Copyright (c) 2014 Taylor Hakes
3+
Copyright (c) 2014 Forbes Lindesay
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<a href="http://promises-aplus.github.com/promises-spec"><img src="http://promises-aplus.github.com/promises-spec/assets/logo-small.png" align="right" alt="Promises/A+ logo" /></a>
2+
# NUO
3+
4+
> :two_hearts: Lightweight ES6 Promise polyfill for the browser and node. Adheres closely to the spec. It is a perfect polyfill IE, Firefox or any other browser that does not support native promises.
5+
6+
[![Travis](https://img.shields.io/travis/crossjs/nuo.svg?style=flat-square)](https://travis-ci.org/crossjs/nuo)
7+
[![Coveralls](https://img.shields.io/coveralls/crossjs/nuo.svg?style=flat-square)](https://coveralls.io/github/crossjs/nuo)
8+
[![dependencies](https://david-dm.org/crossjs/nuo.svg?style=flat-square)](https://david-dm.org/crossjs/nuo)
9+
[![devDependency Status](https://david-dm.org/crossjs/nuo/dev-status.svg?style=flat-square)](https://david-dm.org/crossjs/nuo#info=devDependencies)
10+
[![NPM version](https://img.shields.io/npm/v/nuo.svg?style=flat-square)](https://npmjs.org/package/nuo)
11+
12+
This implementation is based on [taylorhakes/promise-polyfill](https://github.com/taylorhakes/promise-polyfill) and [then/promise](https://github.com/then/promise). It has been changed to use the prototype for performance and memory reasons.
13+
14+
For API information about Promises, please check out this article [HTML5Rocks article](http://www.html5rocks.com/en/tutorials/es6/promises/).
15+
16+
## Browser Support
17+
18+
IE8+, Chrome, Firefox, IOS 4+, Safari 5+, Opera
19+
20+
## Usage
21+
22+
```js
23+
new Nuo(function(resolve, reject, notify) {
24+
// resolve, reject, notify
25+
}).then(function(value) {
26+
// do something
27+
}).catch(function(error) {
28+
// do something
29+
}).progress(function(value) {
30+
// do something
31+
}).finally(function() {
32+
// do something
33+
})
34+
```
35+
36+
### cjs
37+
38+
``` bash
39+
$ npm install nuo
40+
```
41+
42+
### iife
43+
44+
- [nuo](index.js) [minified](index.min.js)
45+
46+
## Example
47+
48+
```js
49+
const nuo = new Nuo(function(resolve, reject) {
50+
// do a thing, possibly async, then…
51+
52+
if (/* everything turned out fine */) {
53+
resolve("Stuff worked!");
54+
} else {
55+
reject(new Error("It broke"));
56+
}
57+
});
58+
59+
// Do something when async done
60+
nuo.then(function() {
61+
...
62+
});
63+
```
64+
65+
## Testing
66+
67+
```bash
68+
npm install
69+
npm test
70+
```
71+
72+
## License
73+
74+
MIT

0 commit comments

Comments
 (0)