Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-bluebird-promises

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-bluebird-promises - npm Package Compare versions

Comparing version 0.5.6 to 0.6.0

2

bower.json
{
"name": "angular-bluebird-promises",
"version": "0.5.6",
"version": "0.6.0",
"homepage": "https://github.com/mattlewis92/angular-bluebird-promises",

@@ -5,0 +5,0 @@ "authors": [

/**
* angular-bluebird-promises - Replaces $q with bluebirds promise API
* @version v0.5.6
* @version v0.6.0
* @link https://github.com/mattlewis92/angular-bluebird-promises

@@ -65,6 +65,18 @@ * @license MIT

var angular = __webpack_require__(1);
var Promise = __webpack_require__(2);
var MODULE_NAME = 'mwl.bluebird';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _angular = __webpack_require__(1);
var _angular2 = _interopRequireDefault(_angular);
var _bluebird = __webpack_require__(2);
var _bluebird2 = _interopRequireDefault(_bluebird);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _typeof(obj) { return obj && obj.constructor === Symbol ? "symbol" : typeof obj; }
// In regards to: https://github.com/petkaantonov/bluebird#for-library-authors

@@ -74,8 +86,8 @@ // My reasoning behind not doing this is to prevent bundling bluebird code with this library

function $qBluebird(resolve, reject) {
return new Promise(resolve, reject);
return new _bluebird2.default(resolve, reject);
}
$qBluebird.prototype = Promise.prototype;
$qBluebird.prototype = _bluebird2.default.prototype;
angular.extend($qBluebird, Promise);
_angular2.default.extend($qBluebird, _bluebird2.default);

@@ -85,8 +97,15 @@ //Make bluebird API compatible with angular's subset of Q

$qBluebird.defer = function() {
var b = $qBluebird.pending();
b.resolve = angular.bind(b, b.fulfill);
b.reject = angular.bind(b, b.reject);
b.notify = angular.bind(b, b.progress);
return b;
$qBluebird.defer = function () {
var deferred = {};
deferred.promise = $qBluebird(function (resolve, reject) {
deferred.resolve = resolve;
deferred.reject = reject;
});
deferred.promise.progressCallbacks = [];
deferred.notify = function (progressValue) {
deferred.promise.progressCallbacks.forEach(function (cb) {
return cb(progressValue);
});
};
return deferred;
};

@@ -98,41 +117,43 @@

var originalAll = $qBluebird.all;
$qBluebird.all = function(promises) {
$qBluebird.all = function (promises) {
if (angular.isObject(promises) && !angular.isArray(promises)) {
if ((typeof promises === 'undefined' ? 'undefined' : _typeof(promises)) === 'object' && !Array.isArray(promises)) {
return $qBluebird.props(promises);
} else {
return originalAll.call($qBluebird, promises);
return originalAll(promises);
}
};
var originalThen = $qBluebird.prototype.then;
$qBluebird.prototype.then = function (fulfilledHandler, rejectedHandler, progressHandler) {
if (this.progressCallbacks) {
this.progressCallbacks.push(progressHandler);
}
return originalThen.call(this, fulfilledHandler, rejectedHandler, progressHandler);
};
var originalFinally = $qBluebird.prototype.finally;
$qBluebird.prototype.finally = function(finallyCallback, progressCallback) {
this.progressed(progressCallback);
return originalFinally.call(this, finallyCallback);
$qBluebird.prototype.finally = function (finallyHandler, progressHandler) {
if (this.progressCallbacks) {
this.progressCallbacks.push(progressHandler);
}
return originalFinally.call(this, finallyHandler);
};
$qBluebird.onPossiblyUnhandledRejection(angular.noop);
$qBluebird.onPossiblyUnhandledRejection(_angular2.default.noop);
angular
.module(MODULE_NAME, [])
.constant('Bluebird', $qBluebird)
.config(["$provide", "Bluebird", function($provide, Bluebird) {
var ngModule = _angular2.default.module('mwl.bluebird', []).constant('Bluebird', $qBluebird).config(["$provide", "Bluebird", function ($provide, Bluebird) {
$provide.decorator('$q', function() {
return Bluebird;
});
$provide.decorator('$q', function () {
return Bluebird;
});
}]).run(["$rootScope", "Bluebird", function ($rootScope, Bluebird) {
}])
.run(["$rootScope", "Bluebird", function($rootScope, Bluebird) {
Bluebird.setScheduler(function (cb) {
return $rootScope.$evalAsync(cb);
});
}]);
Bluebird.setScheduler(function(cb) {
$rootScope.$evalAsync(cb);
});
exports.default = ngModule.name;
}]);
module.exports = MODULE_NAME;
/***/ },

@@ -139,0 +160,0 @@ /* 1 */

/**
* angular-bluebird-promises - Replaces $q with bluebirds promise API
* @version v0.5.6
* @version v0.6.0
* @link https://github.com/mattlewis92/angular-bluebird-promises
* @license MIT
*/
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("angular"),require("bluebird")):"function"==typeof define&&define.amd?define(["angular","bluebird"],r):"object"==typeof exports?exports.angularBluebirdPromisesModuleName=r(require("angular"),require("bluebird")):e.angularBluebirdPromisesModuleName=r(e.angular,e.Promise)}(this,function(e,r){return function(e){function r(o){if(n[o])return n[o].exports;var t=n[o]={exports:{},id:o,loaded:!1};return e[o].call(t.exports,t,t.exports,r),t.loaded=!0,t.exports}var n={};return r.m=e,r.c=n,r.p="",r(0)}([function(e,r,n){"use strict";function o(e,r){return new i(e,r)}var t=n(1),i=n(2),u="mwl.bluebird";o.prototype=i.prototype,t.extend(o,i),o.defer=function(){var e=o.pending();return e.resolve=t.bind(e,e.fulfill),e.reject=t.bind(e,e.reject),e.notify=t.bind(e,e.progress),e},o.reject=o.rejected,o.when=o.cast;var l=o.all;o.all=function(e){return t.isObject(e)&&!t.isArray(e)?o.props(e):l.call(o,e)};var c=o.prototype["finally"];o.prototype["finally"]=function(e,r){return this.progressed(r),c.call(this,e)},o.onPossiblyUnhandledRejection(t.noop),t.module(u,[]).constant("Bluebird",o).config(["$provide","Bluebird",function(e,r){e.decorator("$q",function(){return r})}]).run(["$rootScope","Bluebird",function(e,r){r.setScheduler(function(r){e.$evalAsync(r)})}]),e.exports=u},function(r,n){r.exports=e},function(e,n){e.exports=r}])});
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("angular"),require("bluebird")):"function"==typeof define&&define.amd?define(["angular","bluebird"],r):"object"==typeof exports?exports.angularBluebirdPromisesModuleName=r(require("angular"),require("bluebird")):e.angularBluebirdPromisesModuleName=r(e.angular,e.Promise)}(this,function(e,r){return function(e){function r(o){if(t[o])return t[o].exports;var n=t[o]={exports:{},id:o,loaded:!1};return e[o].call(n.exports,n,n.exports,r),n.loaded=!0,n.exports}var t={};return r.m=e,r.c=t,r.p="",r(0)}([function(e,r,t){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function n(e){return e&&e.constructor===Symbol?"symbol":typeof e}function u(e,r){return new s["default"](e,r)}Object.defineProperty(r,"__esModule",{value:!0});var l=t(1),i=o(l),a=t(2),s=o(a);u.prototype=s["default"].prototype,i["default"].extend(u,s["default"]),u.defer=function(){var e={};return e.promise=u(function(r,t){e.resolve=r,e.reject=t}),e.promise.progressCallbacks=[],e.notify=function(r){e.promise.progressCallbacks.forEach(function(e){return e(r)})},e},u.reject=u.rejected,u.when=u.cast;var c=u.all;u.all=function(e){return"object"!==("undefined"==typeof e?"undefined":n(e))||Array.isArray(e)?c(e):u.props(e)};var f=u.prototype.then;u.prototype.then=function(e,r,t){return this.progressCallbacks&&this.progressCallbacks.push(t),f.call(this,e,r,t)};var p=u.prototype["finally"];u.prototype["finally"]=function(e,r){return this.progressCallbacks&&this.progressCallbacks.push(r),p.call(this,e)},u.onPossiblyUnhandledRejection(i["default"].noop);var d=i["default"].module("mwl.bluebird",[]).constant("Bluebird",u).config(["$provide","Bluebird",function(e,r){e.decorator("$q",function(){return r})}]).run(["$rootScope","Bluebird",function(e,r){r.setScheduler(function(r){return e.$evalAsync(r)})}]);r["default"]=d.name},function(r,t){r.exports=e},function(e,t){e.exports=r}])});
//# sourceMappingURL=angular-bluebird-promises.min.js.map

@@ -1,8 +0,6 @@

// Karma configuration
// Generated on Thu Mar 19 2015 17:35:54 GMT+0000 (GMT)
'use strict';
var WATCH = process.argv.indexOf('--watch') > -1;
var MIN = process.argv.indexOf('--min') > -1;
const WATCH = process.argv.indexOf('--watch') > -1;
var webpackConfig = {
const webpackConfig = {
devtool: 'inline-source-map',

@@ -12,4 +10,9 @@ module: {

test: /.*\.js$/,
loaders: ['eslint'],
loader: 'eslint',
exclude: /node_modules/
}],
loaders: [{
test: /\.js$/,
loader: 'babel?presets[]=es2015',
exclude: /node_modules/
}]

@@ -19,10 +22,2 @@ }

if (MIN) {
webpackConfig.module.loaders = [{
test: /.*src.*\.js$/,
loaders: ['uglify', 'ng-annotate'],
exclude: /node_modules/
}];
}
module.exports = function(config) {

@@ -29,0 +24,0 @@ config.set({

{
"name": "angular-bluebird-promises",
"version": "0.5.6",
"version": "0.6.0",
"description": "Replaces $q with bluebirds promise API",

@@ -23,3 +23,8 @@ "browser": "dist/angular-bluebird-promises.js",

"angular-mocks": ">=1.2.0",
"eslint": "~1.7.3",
"babel-core": "~6.0.14",
"babel-loader": "~6.0.0",
"babel-polyfill": "~6.0.14",
"babel-preset-es2015": "~6.0.14",
"bluebird": "~3.0.2",
"eslint": "~1.8.0",
"eslint-config-mwl": "~0.3.0",

@@ -38,3 +43,2 @@ "eslint-loader": "~1.1.0",

"phantomjs": "~1.9.17",
"uglify-loader": "~1.2.0",
"webpack": "~1.12.2",

@@ -45,9 +49,7 @@ "webpack-dev-server": "~1.12.0"

"angular": ">=1.2.0",
"bluebird": "^2.9.25"
"bluebird": ">=2.0.0"
},
"scripts": {
"test:unmin": "karma start",
"test:min": "karma start --min",
"test:watch": "karma start --watch",
"test": "npm run test:min",
"test": "karma start",
"build:unmin": "webpack --config webpack.config.build.js",

@@ -54,0 +56,0 @@ "build:min": "webpack -p --config webpack.config.build.js",

@@ -1,7 +0,4 @@

'use strict';
import angular from 'angular';
import Promise from 'bluebird';
var angular = require('angular');
var Promise = require('bluebird');
var MODULE_NAME = 'mwl.bluebird';
// In regards to: https://github.com/petkaantonov/bluebird#for-library-authors

@@ -22,7 +19,12 @@ // My reasoning behind not doing this is to prevent bundling bluebird code with this library

$qBluebird.defer = function() {
var b = $qBluebird.pending();
b.resolve = angular.bind(b, b.fulfill);
b.reject = angular.bind(b, b.reject);
b.notify = angular.bind(b, b.progress);
return b;
const deferred = {};
deferred.promise = $qBluebird(function(resolve, reject) {
deferred.resolve = resolve;
deferred.reject = reject;
});
deferred.promise.progressCallbacks = [];
deferred.notify = function(progressValue) {
deferred.promise.progressCallbacks.forEach(cb => cb(progressValue));
};
return deferred;
};

@@ -33,9 +35,9 @@

var originalAll = $qBluebird.all;
const originalAll = $qBluebird.all;
$qBluebird.all = function(promises) {
if (angular.isObject(promises) && !angular.isArray(promises)) {
if (typeof promises === 'object' && !Array.isArray(promises)) {
return $qBluebird.props(promises);
} else {
return originalAll.call($qBluebird, promises);
return originalAll(promises);
}

@@ -45,12 +47,22 @@

var originalFinally = $qBluebird.prototype.finally;
$qBluebird.prototype.finally = function(finallyCallback, progressCallback) {
this.progressed(progressCallback);
return originalFinally.call(this, finallyCallback);
const originalThen = $qBluebird.prototype.then;
$qBluebird.prototype.then = function(fulfilledHandler, rejectedHandler, progressHandler) {
if (this.progressCallbacks) {
this.progressCallbacks.push(progressHandler);
}
return originalThen.call(this, fulfilledHandler, rejectedHandler, progressHandler);
};
const originalFinally = $qBluebird.prototype.finally;
$qBluebird.prototype.finally = function(finallyHandler, progressHandler) {
if (this.progressCallbacks) {
this.progressCallbacks.push(progressHandler);
}
return originalFinally.call(this, finallyHandler);
};
$qBluebird.onPossiblyUnhandledRejection(angular.noop);
angular
.module(MODULE_NAME, [])
const ngModule = angular
.module('mwl.bluebird', [])
.constant('Bluebird', $qBluebird)

@@ -66,8 +78,6 @@ .config(function($provide, Bluebird) {

Bluebird.setScheduler(function(cb) {
$rootScope.$evalAsync(cb);
});
Bluebird.setScheduler((cb) => $rootScope.$evalAsync(cb));
});
module.exports = MODULE_NAME;
export default ngModule.name;

@@ -1,7 +0,6 @@

'use strict';
import 'babel-polyfill';
import angular from 'angular';
import 'angular-mocks';
import './../src/angular-bluebird-promises.js';
var angular = require('angular');
require('angular-mocks');
require('./../src/angular-bluebird-promises.js');
beforeEach(angular.mock.module('mwl.bluebird'));

@@ -11,3 +10,3 @@

var $q, $rootScope;
let $q, $rootScope;

@@ -22,3 +21,3 @@ beforeEach(inject(function(_$q_, _$rootScope_) {

it('should have the resolve, reject and notify methods', function() {
var deferred = $q.defer();
const deferred = $q.defer();
assert.isFunction(deferred.resolve);

@@ -30,5 +29,5 @@ assert.isFunction(deferred.reject);

it('should resolve the promise', function() {
var deferred = $q.defer();
var promise = deferred.promise;
var resolvedValue;
const deferred = $q.defer();
const promise = deferred.promise;
let resolvedValue;
promise.then(function(value) {

@@ -43,17 +42,18 @@ resolvedValue = value;

it('should reject the promise', function() {
var deferred = $q.defer();
var promise = deferred.promise;
var rejectedValue;
const deferred = $q.defer();
const promise = deferred.promise;
let rejectedValue;
promise.catch(function(value) {
rejectedValue = value;
});
deferred.reject('Fail');
const rejectWith = new Error('Fail');
deferred.reject(rejectWith);
$rootScope.$apply();
expect(rejectedValue).to.equal('Fail');
expect(rejectedValue).to.equal(rejectWith);
});
it('should call finally if the promise resolves', function() {
var deferred = $q.defer();
var promise = deferred.promise;
var finallyCb = sinon.spy();
const deferred = $q.defer();
const promise = deferred.promise;
const finallyCb = sinon.spy();
promise.finally(finallyCb);

@@ -66,7 +66,7 @@ deferred.resolve();

it('should call finally if the promise rejects', function() {
var deferred = $q.defer();
var promise = deferred.promise;
var finallyCb = sinon.spy();
const deferred = $q.defer();
const promise = deferred.promise;
const finallyCb = sinon.spy();
promise.finally(finallyCb);
deferred.reject();
deferred.reject(new Error());
$rootScope.$apply();

@@ -78,11 +78,12 @@ expect(finallyCb).to.have.been.calledOnce;

var deferred = $q.defer();
var promise = deferred.promise;
var rejectedValue;
const deferred = $q.defer();
const promise = deferred.promise;
let rejectedValue;
promise.then(angular.noop, function(value) {
rejectedValue = value;
});
deferred.reject('Fail');
const rejectWith = new Error('Fail');
deferred.reject(rejectWith);
$rootScope.$apply();
expect(rejectedValue).to.equal('Fail');
expect(rejectedValue).to.equal(rejectWith);
});

@@ -92,5 +93,5 @@

var deferred = $q.defer();
var promise = deferred.promise;
var progressValue;
const deferred = $q.defer();
const promise = deferred.promise;
let progressValue;
promise.then(angular.noop, angular.noop, function(progress) {

@@ -105,5 +106,5 @@ progressValue = progress;

it('should notify the promise on progress', function() {
var deferred = $q.defer();
var promise = deferred.promise;
var notifyValues = [];
const deferred = $q.defer();
const promise = deferred.promise;
const notifyValues = [];
promise.finally(angular.noop, function(progress) {

@@ -121,3 +122,3 @@ notifyValues.push(progress);

it('should have a promise property which is a promise', function() {
var deferred = $q.defer();
const deferred = $q.defer();
assert.isFunction(deferred.promise.then);

@@ -134,4 +135,4 @@ assert.isFunction(deferred.promise.catch);

var resolve, reject;
var promise = $q(function(_resolve, _reject) {
let resolve, reject;
const promise = $q(function(_resolve, _reject) {
resolve = _resolve;

@@ -151,4 +152,4 @@ reject = _reject;

var resolve, resolvedValue;
var promise = $q(function(_resolve) {
let resolve, resolvedValue;
const promise = $q(function(_resolve) {
resolve = _resolve;

@@ -170,4 +171,4 @@ });

var reject, rejectedValue;
var promise = $q(function(_resolve, _reject) {
let reject, rejectedValue;
const promise = $q(function(_resolve, _reject) {
reject = _reject;

@@ -180,6 +181,8 @@ });

reject('Reject');
const rejectWith = new Error('Reject');
reject(rejectWith);
$rootScope.$apply();
expect(rejectedValue).to.equal('Reject');
expect(rejectedValue).to.equal(rejectWith);

@@ -194,3 +197,4 @@ });

var rejectedPromise = $q.reject('Reject'), rejectedValue;
const rejectWith = new Error('Reject');
let rejectedPromise = $q.reject(rejectWith), rejectedValue;
rejectedPromise.catch(function(_rejectedValue) {

@@ -200,3 +204,3 @@ rejectedValue = _rejectedValue;

$rootScope.$apply();
expect(rejectedValue).to.equal('Reject');
expect(rejectedValue).to.equal(rejectWith);

@@ -211,3 +215,3 @@ });

var rejectedPromise = $q.resolve('Resolve'), resolvedValue;
let rejectedPromise = $q.resolve('Resolve'), resolvedValue;
rejectedPromise.then(function(_resolvedValue) {

@@ -228,3 +232,3 @@ resolvedValue = _resolvedValue;

var results;
let results;
$q.all([

@@ -245,3 +249,3 @@ $q.resolve(1),

var results;
let results;
$q.all({

@@ -265,5 +269,5 @@ item1: $q.resolve(1),

it('should only resolve promises after a digest', function() {
var deferred = $q.defer();
var promise = deferred.promise;
var resolvedValue;
const deferred = $q.defer();
const promise = deferred.promise;
let resolvedValue;
promise.then(function(value) {

@@ -285,3 +289,3 @@ resolvedValue = value;

it('should add the spread method to promise', function() {
var deferred = $q.when();
const deferred = $q.when();
assert.isFunction(deferred.spread);

@@ -288,0 +292,0 @@ });

@@ -39,3 +39,3 @@ 'use strict';

test: /.*\.js$/,
loaders: ['eslint'],
loader: 'eslint',
exclude: /node_modules/

@@ -45,3 +45,3 @@ }],

test: /.*\.js$/,
loaders: ['ng-annotate'],
loader: 'ng-annotate?regexp=angular.*?\\.module\\(.*?\\)$!babel?presets[]=es2015',
exclude: /node_modules/

@@ -48,0 +48,0 @@ }]

@@ -26,4 +26,9 @@ 'use strict';

test: /.*\.js$/,
loaders: ['eslint'],
loader: 'eslint',
exclude: /node_modules/
}],
loaders: [{
test: /\.js$/,
loader: 'babel?presets[]=es2015',
exclude: /node_modules/
}]

@@ -30,0 +35,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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