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

oow

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

oow - npm Package Compare versions

Comparing version 1.3.1 to 1.4.0

76

oow.js

@@ -1,25 +0,53 @@

const Collection = {
isEmpty() { return this.length === 0; },
notEmpty() { return !this.isEmpty(); },
first() { return this[0]; },
last() { return this[this.length-1]; },
any(predicate) {
for (let elem in this)
if (predicate(this[elem])) return true;
return false;
},
all(predicate) {
return !this.any(elem => !predicate(elem));
}
};
// ideal implementation, not recommended
//Object.setPrototypeOf(Array.prototype, Collection);
//Object.setPrototypeOf(String.prototype, Collection);
// implementation w/o changing prototypes hierarchy
Object.keys(Collection).forEach(function (methodName) {
[Array.prototype, String.prototype].forEach(function (proto) {
Object.defineProperty(proto, methodName, { value: Collection[methodName] });
(function () {
const Collection = {
isEmpty() { return this.length === 0; },
notEmpty() { return !this.isEmpty(); },
first() { return this[0]; },
last() { return this[this.length-1]; },
any(predicate) {
for (let elem in this)
if (predicate(this[elem])) return true;
return false;
},
all(predicate) {
return !this.any(elem => !predicate(elem));
},
take(n) { return this.slice(0, n); },
drop(n) { return this.slice(n, this.length); }
};
const ArrayExtensions = {
equals(array) {
if (!array) return false;
if (this.length !== array.length) return false;
for (let i = 0, l=this.length; i < l; i++) {
if (this[i] instanceof Array && array[i] instanceof Array) {
if (!this[i].equals(array[i])) return false;
}
else if (this[i] !== array[i]) {
return false;
}
}
return true;
}
};
let eachExtensionOf = function(extension, block) {
Object.keys(extension).forEach(block)
};
let extend = function(proto, extension, methodName) {
Object.defineProperty(proto, methodName, { value: extension[methodName] });
};
eachExtensionOf(Collection, function (methodName) {
[Array.prototype, String.prototype].forEach(function (proto) {
extend(proto, Collection, methodName);
});
});
});
eachExtensionOf(ArrayExtensions, function (methodName) {
extend(Array.prototype, ArrayExtensions, methodName);
});
})();
{
"name": "oow",
"version": "1.3.1",
"version": "1.4.0",
"description": "Extension methods that should exist in JS core by default",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/ngarbezza/oow",

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