Comparing version 1.0.3 to 1.0.4
106
lib/index.js
'use strict'; | ||
require('./polyfills/Array.prototype.includes'); | ||
require('./polyfills/Array.prototype.every'); | ||
require('./polyfills/Array.from'); | ||
require("babel-polyfill"); | ||
/** | ||
* @param {*} needle | ||
* @param {Array} haystack | ||
* @returns {boolean} | ||
*/ | ||
function _isAnyOf(needle, haystack) { | ||
return haystack.includes(needle); | ||
} | ||
var singleValueAPI = require('./single-api.js'); | ||
var multipleValueAPI = require('./multiple-api.js'); | ||
/** | ||
* @param {*} needle | ||
* @param {Array} haystack | ||
* @returns {boolean} | ||
*/ | ||
function _isNoneOf(needle, haystack) { | ||
return !_isAnyOf(needle, haystack); | ||
} | ||
/** | ||
* @param {*} needle | ||
* @param {Array} haystack | ||
* @returns {boolean} | ||
*/ | ||
function _isAllOf(needle, haystack) { | ||
console.log(needle, haystack); | ||
return haystack.every(function (el) { | ||
return el === needle; | ||
}); | ||
} | ||
/** | ||
* @param {...*} inputValues | ||
* @returns {Object} | ||
* @returns {Object.<string, function>} | ||
*/ | ||
function allege() { | ||
var allege = Object.freeze(function () { | ||
for (var _len = arguments.length, inputValues = Array(_len), _key = 0; _key < _len; _key++) { | ||
@@ -46,72 +17,11 @@ inputValues[_key] = arguments[_key]; | ||
var singleValueAPI = { | ||
/** | ||
* @param {...*} possibilities | ||
* @returns {boolean} | ||
*/ | ||
isAnyOf: function isAnyOf() { | ||
for (var _len2 = arguments.length, possibilities = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
possibilities[_key2] = arguments[_key2]; | ||
} | ||
return _isAnyOf(inputValues[0], Array.from(possibilities)); | ||
}, | ||
/** | ||
* @param {...*} possibilities | ||
* @returns {boolean} | ||
*/ | ||
isNoneOf: function isNoneOf() { | ||
for (var _len3 = arguments.length, possibilities = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
possibilities[_key3] = arguments[_key3]; | ||
} | ||
return _isNoneOf(inputValues[0], Array.from(possibilities)); | ||
}, | ||
/** | ||
* @param {...*} possibilities | ||
* @returns {boolean} | ||
*/ | ||
isAllOf: function isAllOf() { | ||
for (var _len4 = arguments.length, possibilities = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { | ||
possibilities[_key4] = arguments[_key4]; | ||
} | ||
return _isAllOf(inputValues[0], Array.from(possibilities)); | ||
} | ||
}; | ||
var multipleValuesAPI = { | ||
/** | ||
* @param {*} possibility | ||
* @returns {boolean} | ||
*/ | ||
areAll: function areAll(possibility) { | ||
return _isAllOf(possibility, Array.from(inputValues)); | ||
}, | ||
/** | ||
* @param {*} possibility | ||
* @returns {boolean} | ||
*/ | ||
areAllNot: function areAllNot(possibility) { | ||
return _isNoneOf(possibility, Array.from(inputValues)); | ||
} | ||
}; | ||
if (inputValues.length === 1) { | ||
return singleValueAPI; | ||
return singleValueAPI(inputValues[0]); | ||
} else if (inputValues.length > 1) { | ||
return multipleValuesAPI; | ||
return multipleValueAPI(inputValues); | ||
} else { | ||
throw new ReferenceError('allege must be called with at least one argument.'); | ||
} | ||
} | ||
}); | ||
/** | ||
* @type {allege} | ||
*/ | ||
module.exports = allege; |
{ | ||
"name": "allege", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Make complex conditionals easier to read and write", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"transpile-to-es5": "babel src --out-dir lib", | ||
"prepublish": "npm run transpile-to-es5" | ||
"test": "mocha test test/", | ||
"build": "babel src/ -d lib/" | ||
}, | ||
@@ -24,4 +23,8 @@ "repository": { | ||
"devDependencies": { | ||
"babel": "^5.8.34" | ||
"babel-cli": "^6.5.1", | ||
"babel-preset-es2015": "^6.5.0", | ||
"babelify": "^7.2.0", | ||
"expect.js": "^0.3.1", | ||
"mocha": "^2.4.5" | ||
} | ||
} |
'use strict'; | ||
require('./polyfills/Array.prototype.includes'); | ||
require('./polyfills/Array.prototype.every'); | ||
require('./polyfills/Array.from'); | ||
require("babel-polyfill"); | ||
/** | ||
* @param {*} needle | ||
* @param {Array} haystack | ||
* @returns {boolean} | ||
*/ | ||
function isAnyOf(needle, haystack) { | ||
return haystack.includes(needle); | ||
} | ||
const singleValueAPI = require('./single-api.js'); | ||
const multipleValueAPI = require('./multiple-api.js'); | ||
/** | ||
* @param {*} needle | ||
* @param {Array} haystack | ||
* @returns {boolean} | ||
*/ | ||
function isNoneOf(needle, haystack) { | ||
return !isAnyOf(needle, haystack); | ||
} | ||
/** | ||
* @param {*} needle | ||
* @param {Array} haystack | ||
* @returns {boolean} | ||
*/ | ||
function isAllOf(needle, haystack) { | ||
console.log(needle, haystack); | ||
return haystack.every(function(el) { | ||
return el === needle; | ||
}); | ||
} | ||
/** | ||
* @param {...*} inputValues | ||
* @returns {Object} | ||
* @returns {Object.<string, function>} | ||
*/ | ||
function allege(...inputValues) { | ||
const singleValueAPI = { | ||
/** | ||
* @param {...*} possibilities | ||
* @returns {boolean} | ||
*/ | ||
isAnyOf: function(...possibilities) { | ||
return isAnyOf(inputValues[0], Array.from(possibilities)); | ||
}, | ||
/** | ||
* @param {...*} possibilities | ||
* @returns {boolean} | ||
*/ | ||
isNoneOf: function(...possibilities) { | ||
return isNoneOf(inputValues[0], Array.from(possibilities)); | ||
}, | ||
/** | ||
* @param {...*} possibilities | ||
* @returns {boolean} | ||
*/ | ||
isAllOf: function(...possibilities) { | ||
return isAllOf(inputValues[0], Array.from(possibilities)); | ||
} | ||
}; | ||
const multipleValuesAPI = { | ||
/** | ||
* @param {*} possibility | ||
* @returns {boolean} | ||
*/ | ||
areAll: function(possibility) { | ||
return isAllOf(possibility, Array.from(inputValues)); | ||
}, | ||
/** | ||
* @param {*} possibility | ||
* @returns {boolean} | ||
*/ | ||
areAllNot: function(possibility) { | ||
return isNoneOf(possibility, Array.from(inputValues)); | ||
} | ||
}; | ||
const allege = Object.freeze((...inputValues) => { | ||
if (inputValues.length === 1) { | ||
return singleValueAPI; | ||
return singleValueAPI(inputValues[0]); | ||
} else if (inputValues.length > 1) { | ||
return multipleValuesAPI; | ||
return multipleValueAPI(inputValues); | ||
} else { | ||
throw new ReferenceError('allege must be called with at least one argument.'); | ||
} | ||
} | ||
}); | ||
/** | ||
* @type {allege} | ||
*/ | ||
module.exports = allege; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
40198
23
0
5
287
1