New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

esfunctional

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esfunctional - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

94

lib/v1/index.js
'use strict';
let chalk = require('chalk');
// es6 functional helpers globals

@@ -457,1 +459,93 @@

global.byId = {_id: 1};
// test helper -- lacks
let mustHaveOut = (prefix, color, indent, key, value, comment) => (
chalk.bold[color](prefix) +
' ' +
chalk[color](
new Array(indent + 1).join(' ') +
(key == null ? '' : JSON.stringify(key) + ' : ') +
value
) +
(comment ? chalk.bold.yellow(' // ') + chalk.yellow(comment) : '') + '\n'
);
let mustHaveIter = function(that, key, indent) {
//jshint maxcomplexity: 13
let typeOf = (value) => (
value === undefined ? 'undefined' :
value === null ? 'null' :
value instanceof Function ? value.name :
value.constructor.name
);
let typeOfThis = typeOf(this);
let typeOfThat = typeOf(that);
indent |= 0;
if (typeOfThis !== typeOfThat) {
return (
mustHaveOut('+', 'green', indent, key, typeOfThat, 'should be of type, ...') +
mustHaveOut('-', 'red', indent, key, typeOfThis, '... but is of type.')
);
}
if (that instanceof Function) return '';
let isArray = typeOfThis === 'Array';
if (!isArray && typeOfThis !== 'Object') return this === that ? '' : (
mustHaveOut('+', 'green', indent, key, JSON.stringify(that), 'should be value, ...') +
mustHaveOut('-', 'red', indent, key, JSON.stringify(this), '... but is value.')
);
let out = '';
let hasError = false;
for (let subkey in that) {
let outkey = isArray ? null : subkey;
if (that[subkey] === undefined && (subkey in this)) {
out += mustHaveOut('-', 'red', indent + 1, outkey, typeOf(this[subkey]), 'should not exist, but is of type.');
hasError = true;
} else if (that[subkey] !== undefined && !(subkey in this)) {
out += mustHaveOut('+', 'green', indent + 1, outkey, typeOf(that[subkey]), 'should be of type, but not exist.');
hasError = true;
} else {
let line = mustHaveIter.call(this[subkey], that[subkey], outkey, indent + 1);
if (line) {
out += line;
hasError = true;
} else {
out += mustHaveOut('.', 'gray', indent + 1, outkey, typeOf(that[subkey]));
}
}
}
if (hasError) {
if (isArray) return (
mustHaveOut('\\', 'cyan', indent, key, '[') + out + mustHaveOut('/', 'cyan', indent, null, ']')
);
return mustHaveOut('\\', 'cyan', indent, key, '{') + out + mustHaveOut('/', 'cyan', indent, null, '}');
}
return '';
};
global.lacks = Symbol('lacks');
Object.prototype[global.lacks] = function(that) {
let out = mustHaveIter.call(this, that);
if (out) {
console.log(out);
return true;
}
return false;
};

3

package.json
{
"name": "esfunctional",
"version": "1.0.8",
"version": "1.0.9",
"description": "Next Generation EcmaScript Functional Helpers",

@@ -26,4 +26,5 @@ "main": "lib/v1/index.js",

"dependencies": {
"chalk": "1.1.1",
"lodash": "3.10.1"
}
}
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