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

native-or-another

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

native-or-another - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

.coveralls.yml

41

history.md

@@ -0,37 +1,6 @@

## v2.0.0 / December 21, 2014
- change the purpose of library
- now exports deferred object
## v1.0.0 / October 28, 2014
- initial release
[npmjs-url]: http://npm.im/native-or-another
[npmjs-shields]: http://img.shields.io/npm/v/native-or-another.svg
[npmjs-install]: https://nodei.co/npm/native-or-another.svg?mini=true
[coveralls-url]: https://coveralls.io/r/tunnckoCore/native-or-another?branch=master
[coveralls-shields]: https://img.shields.io/coveralls/tunnckoCore/native-or-another.svg
[license-url]: https://github.com/tunnckoCore/native-or-another/blob/master/license.md
[license-img]: http://img.shields.io/badge/license-MIT-blue.svg
[travis-url]: https://travis-ci.org/tunnckoCore/native-or-another
[travis-img]: https://travis-ci.org/tunnckoCore/native-or-another.svg?branch=master
[depstat-url]: https://david-dm.org/tunnckoCore/native-or-another
[depstat-img]: https://david-dm.org/tunnckoCore/native-or-another.svg
[author-gittip-img]: http://img.shields.io/gittip/tunnckoCore.svg
[author-gittip]: https://www.gittip.com/tunnckoCore
[author-github]: https://github.com/tunnckoCore
[author-twitter]: https://twitter.com/tunnckoCore
[author-website]: http://www.whistle-bg.tk
[author-npmjs]: https://npmjs.org/~tunnckocore
[cobody-url]: https://github.com/tj/co-body
[mocha-url]: https://github.com/tj/mocha
[rawbody-url]: https://github.com/stream-utils/raw-body
[multer-url]: https://github.com/expressjs/multer
[express-url]: https://github.com/strongloop/express
[formidable-url]: https://github.com/felixge/node-formidable
[co-url]: https://github.com/tj/co
[extend-url]: https://github.com/justmoon/node-extend
[csp-report]: https://mathiasbynens.be/notes/csp-reports
- initial release
/**
* native-or-anothor <https://github.com/tunnckoCore/native-or-anothor>
* native-or-another <https://github.com/tunnckoCore/native-or-another>
*

@@ -10,11 +10,13 @@ * Copyright (c) 2014 Charlike Mike Reagent, contributors.

var PROMISE_LIB = 'micropromise';
module.exports = require('./promise')
var Promize = require('native-or-bluebird');
/* istanbul ignore next */
if (!module.exports) {
console.error('The file "%s" requires `Promise`,', module.parent.filename)
console.error('but neither `%s` nor the native `Promise` implementation were found.', PROMISE_LIB)
console.error('Please install `%s` yourself.', PROMISE_LIB)
process.exit(1)
}
module.exports = function PromiseDeferred() {
var deferred = {};
deferred.promise = new Promize(function(resolve, reject) {
deferred.resolve = resolve;
deferred.reject = reject;
});
return deferred;
};

@@ -1,2 +0,2 @@

Copyright (c) 2014 [Charlike Mike Reagent][author-website], [contributors](https://github.com/tunnckoCore/native-or-another/graphs/contributors).
Copyright (c) 2014 [Charlike Make Reagent](http://j.mp/1stW47C), contributors

@@ -22,38 +22,2 @@ Permission is hereby granted, free of charge, to any person

FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
[npmjs-url]: http://npm.im/native-or-another
[npmjs-shields]: http://img.shields.io/npm/v/native-or-another.svg
[npmjs-install]: https://nodei.co/npm/native-or-another.svg?mini=true
[coveralls-url]: https://coveralls.io/r/tunnckoCore/native-or-another?branch=master
[coveralls-shields]: https://img.shields.io/coveralls/tunnckoCore/native-or-another.svg
[license-url]: https://github.com/tunnckoCore/native-or-another/blob/master/license.md
[license-img]: http://img.shields.io/badge/license-MIT-blue.svg
[travis-url]: https://travis-ci.org/tunnckoCore/native-or-another
[travis-img]: https://travis-ci.org/tunnckoCore/native-or-another.svg?branch=master
[depstat-url]: https://david-dm.org/tunnckoCore/native-or-another
[depstat-img]: https://david-dm.org/tunnckoCore/native-or-another.svg
[author-gittip-img]: http://img.shields.io/gittip/tunnckoCore.svg
[author-gittip]: https://www.gittip.com/tunnckoCore
[author-github]: https://github.com/tunnckoCore
[author-twitter]: https://twitter.com/tunnckoCore
[author-website]: http://www.whistle-bg.tk
[author-npmjs]: https://npmjs.org/~tunnckocore
[cobody-url]: https://github.com/tj/co-body
[mocha-url]: https://github.com/tj/mocha
[rawbody-url]: https://github.com/stream-utils/raw-body
[multer-url]: https://github.com/expressjs/multer
[express-url]: https://github.com/strongloop/express
[formidable-url]: https://github.com/felixge/node-formidable
[co-url]: https://github.com/tj/co
[extend-url]: https://github.com/justmoon/node-extend
[csp-report]: https://mathiasbynens.be/notes/csp-reports
OTHER DEALINGS IN THE SOFTWARE.
{
"name": "native-or-another",
"version": "1.0.0",
"description": "Use either the native Promise or Micropromise (or another)",
"main": "index.js",
"version": "2.0.0",
"description": "Export either the native Promise or Bluebird (using native-or-bluebird) as deferred object.",
"scripts": {
"lint": "npm install && ./node_modules/.bin/jshint ./*.js",
"test": "npm run lint && NODE_ENV=test ./node_modules/.bin/mocha",
"test-cov": "npm test && NODE_ENV=test node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha",
"test-travis": "npm test && NODE_ENV=test node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly"
"lint": "jshint . && jscs . --reporter inline",
"test": "mocha",
"test-cov": "istanbul cover _mocha",
"test-travis": "istanbul cover _mocha --report lcovonly"
},

@@ -15,4 +14,3 @@ "author": {

"email": "mameto_100@mail.bg",
"url": "https://github.com/tunnckoCore",
"twitter": "https://twitter.com/tunnckoCore"
"url": "https://github.com/tunnckoCore"
},

@@ -24,22 +22,26 @@ "repository": {

"keywords": [
"aplus",
"bluebird",
"deferred",
"export",
"exports",
"native",
"object",
"promise",
"promises",
"promises-aplus",
"micropromise",
"micro",
"Promises/A+"
"promises-aplus"
],
"dependencies": {},
"devDependencies": {
"coveralls": "*",
"istanbul": "*",
"jshint": "*",
"mocha": ">=2",
"micropromise": "~0.4.6",
"mocha-lcov-reporter": "*"
},
"licenses": [{
"license": {
"type": "MIT",
"url": "https://github.com/tunnckoCore/native-or-another/blob/master/license.md"
}]
},
"dependencies": {
"native-or-bluebird": "^1.1.2"
},
"devDependencies": {
"bluebird": "^2.4.1",
"istanbul-harmony": "^0.3.1",
"mocha": "^2.0.1",
"mocha-lcov-reporter": "^0.0.1"
}
}

@@ -1,86 +0,80 @@

# native-or-another [![NPM version][npmjs-shields]][npmjs-url] [![Build Status][travis-img]][travis-url] [![Coveralls][coveralls-shields]][coveralls-url]
> Use either the native Promise or [Micropromise](https://github.com/kaerus-component/uP) for now, may change in the future. If no implementation is found, an error will be thrown.
Idea from [native-or-bluebird](https://github.com/normalize/native-or-bluebird)
[![npm version][npmjs-img]][npmjs-url]
[![mit license][license-img]][license-url]
[![build status][travis-img]][travis-url]
[![coverage status][coveralls-img]][coveralls-url]
[![deps status][daviddm-img]][daviddm-url]
## Install [![Nodei.co stats][npmjs-install]][npmjs-url]
> Install with [npm](https://npmjs.org)
> Export either the native Promise or Bluebird (using native-or-bluebird) as deferred object.
```
## Install
```bash
$ npm install native-or-another
$ npm test
```
## Usage
```js
var Promise = require('native-or-another');
```
> For more use-cases see the [tests](./test.js)
The goal of this library is to be able to eventually remove this line
from your code and use native `Promise`s, allowing you to
to write future-compatible code with ease.
You should install `micropromise` in your libraries for maximum compatibility.
If you do not want an error to be thrown,
`require()` the `Promise` implementation directly.
If no implementation is found, `undefined` will be returned.
```js
var Promise = require('native-or-another/promise');
if (Promise) // do stuff with promises
```
var assert = require('assert');
var Deferred = require('native-or-another');
var defer = new Deferred();
## Tests
> As usual - `npm test` **or** if you have [mocha][mocha-url] globally - `mocha`.
defer.resolve(1);
defer.promise.then(function fulfilled(val) {
assert.strictEqual(val, 1);
done();
});
// catching errors
defer.reject(new Error('custom error'));
defer.promise.catch(function rejected(err) {
assert.ok(err instanceof Error);
assert.strictEqual(err.message, 'custom error');
done();
});
```
$ npm test
```
## Authors & Contributors [![author tips][author-gittip-img]][author-gittip]
## Author
**Charlike Mike Reagent**
+ [gittip/tunnckoCore][author-gittip]
+ [gratipay/tunnckoCore][author-gratipay]
+ [twitter/tunnckoCore][author-twitter]
+ [github/tunnckoCore][author-github]
+ [twitter/tunnckoCore][author-twitter]
+ [npmjs/tunnckoCore][author-npmjs]
+ [more ...][contrib-more]
## License [![MIT license][license-img]][license-url]
Copyright (c) 2014 [Charlike Mike Reagent][author-website], [contributors](https://github.com/tunnckoCore/native-or-another/graphs/contributors).
Copyright (c) 2014 [Charlike Mike Reagent][contrib-more], [contributors][contrib-graf].
Released under the [`MIT`][license-url] license.
[npmjs-url]: http://npm.im/native-or-another
[npmjs-shields]: http://img.shields.io/npm/v/native-or-another.svg
[npmjs-install]: https://nodei.co/npm/native-or-another.svg?mini=true
[npmjs-img]: https://img.shields.io/npm/v/native-or-another.svg?style=flat&label=native-or-another
[coveralls-url]: https://coveralls.io/r/tunnckoCore/native-or-another?branch=master
[coveralls-shields]: https://img.shields.io/coveralls/tunnckoCore/native-or-another.svg
[coveralls-img]: https://img.shields.io/coveralls/tunnckoCore/native-or-another.svg?style=flat
[license-url]: https://github.com/tunnckoCore/native-or-another/blob/master/license.md
[license-img]: http://img.shields.io/badge/license-MIT-blue.svg
[license-img]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat
[travis-url]: https://travis-ci.org/tunnckoCore/native-or-another
[travis-img]: https://travis-ci.org/tunnckoCore/native-or-another.svg?branch=master
[travis-img]: https://img.shields.io/travis/tunnckoCore/native-or-another.svg?style=flat
[depstat-url]: https://david-dm.org/tunnckoCore/native-or-another
[depstat-img]: https://david-dm.org/tunnckoCore/native-or-another.svg
[daviddm-url]: https://david-dm.org/tunnckoCore/native-or-another
[daviddm-img]: https://img.shields.io/david/tunnckoCore/native-or-another.svg?style=flat
[author-gittip-img]: http://img.shields.io/gittip/tunnckoCore.svg
[author-gittip]: https://www.gittip.com/tunnckoCore
[author-gratipay]: https://gratipay.com/tunnckoCore
[author-twitter]: https://twitter.com/tunnckoCore
[author-github]: https://github.com/tunnckoCore
[author-twitter]: https://twitter.com/tunnckoCore
[author-website]: http://www.whistle-bg.tk
[author-npmjs]: https://npmjs.org/~tunnckocore
[cobody-url]: https://github.com/tj/co-body
[mocha-url]: https://github.com/tj/mocha
[rawbody-url]: https://github.com/stream-utils/raw-body
[multer-url]: https://github.com/expressjs/multer
[express-url]: https://github.com/strongloop/express
[formidable-url]: https://github.com/felixge/node-formidable
[co-url]: https://github.com/tj/co
[extend-url]: https://github.com/justmoon/node-extend
[csp-report]: https://mathiasbynens.be/notes/csp-reports
[contrib-more]: http://j.mp/1stW47C
[contrib-graf]: https://github.com/tunnckoCore/native-or-another/graphs/contributors
***
_Powered and automated by [readdirp + hogan.js](https://github.com/tunnckoCore), December 21, 2014_
/**
* native-or-anothor <https://github.com/tunnckoCore/native-or-anothor>
* native-or-another <https://github.com/tunnckoCore/native-or-another>
*

@@ -10,30 +10,26 @@ * Copyright (c) 2014 Charlike Mike Reagent, contributors.

/**
* Module dependencies.
*/
var assert = require('assert')
var Promize = null;
var assert = require('assert');
var Deferred = require('./index');
describe('require("native-or-anothor")', function () {
it('should return a Promise implementation', function () {
Promize = require('./index');
describe('require("native-or-another")', function() {
it('should return deferred Promise implementation', function(done) {
var defer = new Deferred();
return new Promize(function (resolve) {
resolve(1)
}).then(function (val) {
assert.equal(val, 1)
})
})
})
defer.resolve(1);
defer.promise.then(function fulfilled(val) {
assert.strictEqual(val, 1);
done();
});
});
describe('require("native-or-anothor/promise")', function () {
it('should return a Promise implementation', function () {
Promize = require('./promise')
it('should catch errors correctly', function(done) {
var defer = new Deferred();
return new Promize(function (resolve) {
resolve(1)
}).then(function (val) {
assert.equal(val, 1)
})
})
})
defer.reject(new Error('custom error'));
defer.promise.catch(function rejected(err) {
assert.ok(err instanceof Error);
assert.strictEqual(err.message, 'custom error');
done();
});
});
});

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

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