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

mixinable

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mixinable - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

LICENSE

10

CHANGELOG.md

@@ -5,2 +5,12 @@ # Change Log

<a name="1.4.0"></a>
# [1.4.0](https://github.com/untool/mixinable/compare/v1.3.0...v1.4.0) (2018-03-06)
### Features
* add sync helper export ([c7ab765](https://github.com/untool/mixinable/commit/c7ab765))
<a name="1.3.0"></a>

@@ -7,0 +17,0 @@ # [1.3.0](https://github.com/dmbch/mixinable/compare/v1.2.1...v1.3.0) (2018-01-30)

32

index.js

@@ -59,15 +59,30 @@ 'use strict';

override: function overrideAsync () {
return promisify(exports.override.apply(null, arguments));
return ensureAsync(exports.override.apply(null, arguments));
},
parallel: function parallelAsync () {
return promisify(exports.parallel.apply(null, arguments));
return ensureAsync(exports.parallel.apply(null, arguments));
},
pipe: function pipeAsync () {
return promisify(exports.pipe.apply(null, arguments));
return ensureAsync(exports.pipe.apply(null, arguments));
},
compose: function composeAsync () {
return promisify(exports.compose.apply(null, arguments));
return ensureAsync(exports.compose.apply(null, arguments));
}
};
exports.sync = {
override: function overrideSync () {
return ensureSync(exports.override.apply(null, arguments));
},
parallel: function parallelSync () {
return ensureSync(exports.parallel.apply(null, arguments));
},
pipe: function pipeSync () {
return ensureSync(exports.pipe.apply(null, arguments));
},
compose: function composeSync () {
return ensureSync(exports.compose.apply(null, arguments));
}
};
exports.isMixinable = function isMixinable (obj) {

@@ -200,4 +215,11 @@ return obj && '__implementations__' in obj && '__arguments__' in obj;

function promisify (obj) {
function ensureAsync (obj) {
return isPromise(obj) ? obj : Promise.resolve(obj);
}
function ensureSync (obj) {
if (isPromise(obj)) {
throw new Error('got promise in sync mode');
}
return obj;
}

8

package.json
{
"name": "mixinable",
"version": "1.3.0",
"version": "1.4.0",
"description": "Functional JavaScript Mixin Utility",

@@ -14,3 +14,3 @@ "main": "index.js",

"type": "git",
"url": "git+https://github.com/dmbch/mixinable.git"
"url": "git+https://github.com/untool/mixinable.git"
},

@@ -20,5 +20,5 @@ "author": "dmbch",

"bugs": {
"url": "https://github.com/dmbch/mixinable/issues"
"url": "https://github.com/untool/mixinable/issues"
},
"homepage": "https://github.com/dmbch/mixinable#readme",
"homepage": "https://github.com/untool/mixinable#readme",
"devDependencies": {

@@ -25,0 +25,0 @@ "semistandard": "^11.0.0",

# Mixinable
[![travis](https://img.shields.io/travis/dmbch/mixinable.svg)](https://travis-ci.org/dmbch/mixinable)&nbsp;[![npm](https://img.shields.io/npm/v/mixinable.svg)](https://www.npmjs.com/package/mixinable)
[![travis](https://img.shields.io/travis/untool/mixinable.svg)](https://travis-ci.org/untool/mixinable)&nbsp;[![npm](https://img.shields.io/npm/v/mixinable.svg)](https://www.npmjs.com/package/mixinable)
<br/>

@@ -5,0 +5,0 @@

@@ -7,2 +7,3 @@ 'use strict';

var async = mixinable.async;
var sync = mixinable.sync;

@@ -21,2 +22,6 @@ test('exports test', function (t) {

t.equal(typeof async.compose, 'function', 'async.compose is a function');
t.equal(typeof sync.override, 'function', 'sync.override is a function');
t.equal(typeof sync.parallel, 'function', 'sync.parallel is a function');
t.equal(typeof sync.pipe, 'function', 'sync.pipe is a function');
t.equal(typeof sync.compose, 'function', 'sync.compose is a function');
t.end();

@@ -471,2 +476,21 @@ });

test('sync helper test', function (t) {
var instance = mixinable({
foo: sync.override,
bar: sync.parallel,
baz: sync.pipe,
qux: sync.compose
})({
foo: function () { return Promise.resolve(); },
bar: function () { return Promise.resolve(); },
baz: function () { return Promise.resolve(); },
qux: function () { return Promise.resolve(); }
})();
t.throws(instance.foo, 'override throws if result is a promise');
t.throws(instance.bar, 'parallel throws if result is a promise');
t.throws(instance.baz, 'pipe throws if result is a promise');
t.throws(instance.qux, 'compose throws if result is a promise');
t.end();
});
test('isMixinable function test', function (t) {

@@ -473,0 +497,0 @@ t.notOk(mixinable.isMixinable(), 'non-mixinable is detected');

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