react app

This commit is contained in:
Mario Romano
2016-04-07 15:33:50 +01:00
parent f32e53a835
commit 2a8113835a
55 changed files with 17175 additions and 177 deletions

View File

@@ -0,0 +1,40 @@
{
"name": "promise-polyfill",
"version": "1.0.0",
"homepage": "https://github.com/taylorhakes/promise-polyfill",
"authors": [
"Taylor Hakes"
],
"description": "Lightweight promise polyfill for the browser and node. A+ Compliant.",
"main": "Promise.js",
"moduleType": [
"globals",
"node"
],
"keywords": [
"promise",
"es6",
"polyfill",
"html5"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"polymer": "polymer/polymer#^1.0.0"
},
"_release": "1.0.0",
"_resolution": {
"type": "version",
"tag": "v1.0.0",
"commit": "2ef7dada161cae30e69ffff918485c57121d4b88"
},
"_source": "git://github.com/polymerlabs/promise-polyfill.git",
"_target": "^1.0.0",
"_originalSource": "polymerlabs/promise-polyfill"
}

View File

@@ -0,0 +1,40 @@
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= pkg.version %> */\n'
},
dist: {
files: {
'Promise.min.uglify.js': ['Promise.js']
}
}
},
closurecompiler: {
options: {
compilation_level: 'ADVANCED_OPTIMIZATIONS',
},
dist: {
files: {
'Promise.min.js': ['Promise.js']
}
}
},
bytesize: {
dist: {
src: ['Promise*.js']
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-closurecompiler');
grunt.loadNpmTasks('grunt-bytesize');
grunt.registerTask('build', ['closurecompiler', 'bytesize']);
};

View File

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

View File

@@ -0,0 +1,36 @@
Promise.all = Promise.all || function () {
var args = Array.prototype.slice.call(arguments.length === 1 && Array.isArray(arguments[0]) ? arguments[0] : arguments);
return new Promise(function (resolve, reject) {
if (args.length === 0) return resolve([]);
var remaining = args.length;
function res(i, val) {
try {
if (val && (typeof val === 'object' || typeof val === 'function')) {
var then = val.then;
if (typeof then === 'function') {
then.call(val, function (val) { res(i, val) }, reject);
return;
}
}
args[i] = val;
if (--remaining === 0) {
resolve(args);
}
} catch (ex) {
reject(ex);
}
}
for (var i = 0; i < args.length; i++) {
res(i, args[i]);
}
});
};
Promise.race = Promise.race || function (values) {
return new Promise(function (resolve, reject) {
for(var i = 0, len = values.length; i < len; i++) {
values[i].then(resolve, reject);
}
});
};

View File

@@ -0,0 +1,127 @@
function MakePromise (asap) {
function Promise(fn) {
if (typeof this !== 'object' || typeof fn !== 'function') throw new TypeError();
this._state = null;
this._value = null;
this._deferreds = []
doResolve(fn, resolve.bind(this), reject.bind(this));
}
function handle(deferred) {
var me = this;
if (this._state === null) {
this._deferreds.push(deferred);
return
}
asap(function() {
var cb = me._state ? deferred.onFulfilled : deferred.onRejected
if (typeof cb !== 'function') {
(me._state ? deferred.resolve : deferred.reject)(me._value);
return;
}
var ret;
try {
ret = cb(me._value);
}
catch (e) {
deferred.reject(e);
return;
}
deferred.resolve(ret);
})
}
function resolve(newValue) {
try { //Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
if (newValue === this) throw new TypeError();
if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) {
var then = newValue.then;
if (typeof then === 'function') {
doResolve(then.bind(newValue), resolve.bind(this), reject.bind(this));
return;
}
}
this._state = true;
this._value = newValue;
finale.call(this);
} catch (e) { reject.call(this, e); }
}
function reject(newValue) {
this._state = false;
this._value = newValue;
finale.call(this);
}
function finale() {
for (var i = 0, len = this._deferreds.length; i < len; i++) {
handle.call(this, this._deferreds[i]);
}
this._deferreds = null;
}
/**
* Take a potentially misbehaving resolver function and make sure
* onFulfilled and onRejected are only called once.
*
* Makes no guarantees about asynchrony.
*/
function doResolve(fn, onFulfilled, onRejected) {
var done = false;
try {
fn(function (value) {
if (done) return;
done = true;
onFulfilled(value);
}, function (reason) {
if (done) return;
done = true;
onRejected(reason);
})
} catch (ex) {
if (done) return;
done = true;
onRejected(ex);
}
}
Promise.prototype['catch'] = function (onRejected) {
return this.then(null, onRejected);
};
Promise.prototype.then = function(onFulfilled, onRejected) {
var me = this;
return new Promise(function(resolve, reject) {
handle.call(me, {
onFulfilled: onFulfilled,
onRejected: onRejected,
resolve: resolve,
reject: reject
});
})
};
Promise.resolve = function (value) {
if (value && typeof value === 'object' && value.constructor === Promise) {
return value;
}
return new Promise(function (resolve) {
resolve(value);
});
};
Promise.reject = function (value) {
return new Promise(function (resolve, reject) {
reject(value);
});
};
return Promise;
}
if (typeof module !== 'undefined') {
module.exports = MakePromise;
}

View File

@@ -0,0 +1,3 @@
function m(n){function b(a){if("object"!==typeof this||"function"!==typeof a)throw new TypeError;this.c=this.a=null;this.b=[];g(a,h.bind(this),d.bind(this))}function k(a){var c=this;null===this.a?this.b.push(a):n(function(){var f=c.a?a.d:a.e;if("function"!==typeof f)(c.a?a.resolve:a.reject)(c.c);else{var e;try{e=f(c.c)}catch(b){a.reject(b);return}a.resolve(e)}})}function h(a){try{if(a===this)throw new TypeError;if(a&&("object"===typeof a||"function"===typeof a)){var c=a.then;if("function"===typeof c){g(c.bind(a),
h.bind(this),d.bind(this));return}}this.a=!0;this.c=a;l.call(this)}catch(b){d.call(this,b)}}function d(a){this.a=!1;this.c=a;l.call(this)}function l(){for(var a=0,c=this.b.length;a<c;a++)k.call(this,this.b[a]);this.b=null}function g(a,c,b){var e=!1;try{a(function(a){e||(e=!0,c(a))},function(a){e||(e=!0,b(a))})}catch(d){e||(e=!0,b(d))}}b.prototype["catch"]=function(a){return this.then(null,a)};b.prototype.then=function(a,c){var f=this;return new b(function(b,d){k.call(f,{d:a,e:c,resolve:b,reject:d})})};
b.resolve=function(a){return a&&"object"===typeof a&&a.constructor===b?a:new b(function(b){b(a)})};b.reject=function(a){return new b(function(b,d){d(a)})};return b}"undefined"!==typeof module&&(module.f=m);

View File

@@ -0,0 +1,13 @@
# Promise Polyfill
Note: this is an unsolicited fork of [taylorhakes/promise-polyfill](https://github.com/taylorhakes/promise-polyfill)
and should be considered experimental and unstable compared to upstream.
## Testing
```
npm install
npm test
```
## License
MIT

View File

@@ -0,0 +1,31 @@
{
"name": "promise-polyfill",
"version": "1.0.0",
"homepage": "https://github.com/taylorhakes/promise-polyfill",
"authors": [
"Taylor Hakes"
],
"description": "Lightweight promise polyfill for the browser and node. A+ Compliant.",
"main": "Promise.js",
"moduleType": [
"globals",
"node"
],
"keywords": [
"promise",
"es6",
"polyfill",
"html5"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"polymer": "polymer/polymer#^1.0.0"
}
}

View File

@@ -0,0 +1,35 @@
{
"name": "promise-polyfill",
"version": "2.0.0",
"description": "Lightweight promise polyfill. A+ compliant",
"main": "Promise.js",
"scripts": {
"test": "./node_modules/.bin/promises-aplus-tests tests/adapter.js; ./node_modules/.bin/promises-es6-tests tests/adapter.js"
},
"repository": {
"type": "git",
"url": "https://taylorhakes@github.com/taylorhakes/promise-polyfill.git"
},
"author": "Taylor Hakes",
"license": "MIT",
"bugs": {
"url": "https://github.com/taylorhakes/promise-polyfill/issues"
},
"homepage": "https://github.com/taylorhakes/promise-polyfill",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-bytesize": "^0.1.1",
"grunt-closurecompiler": "^0.9.9",
"grunt-contrib-uglify": "^0.4.0",
"mocha": "^2.2.1",
"promises-aplus-tests": "*",
"promises-es6-tests": "^0.5.0"
},
"keywords": [
"promise",
"promise-polyfill",
"ES6",
"promises-aplus"
],
"dependencies": {}
}

View File

@@ -0,0 +1,7 @@
<link rel="import" href="../polymer/polymer.html">
<script src='./Promise.js'></script>
<script>
if (!window.Promise) {
window.Promise = MakePromise(Polymer.Base.async);
}
</script>

View File

@@ -0,0 +1,2 @@
<link rel="import" href="./promise-polyfill-lite.html">
<script src='./Promise-Statics.js'></script>