Socket
Socket
Sign inDemoInstall

mol-proto

Package Overview
Dependencies
0
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.2 to 0.0.4

bower.json

55

lib/proto.js

@@ -6,6 +6,7 @@ 'use strict';

extendProto: extendProto,
createSubclass: createSubclass,
makeSubclass: makeSubclass,
extend: extend,
clone: clone,
createSubclass: createSubclass,
makeSubclass: makeSubclass,
deepExtend: deepExtend,
allKeys: Object.getOwnPropertyNames.bind(Object),

@@ -18,2 +19,3 @@ keyOf: keyOf,

prependArray: prependArray,
toArray: toArray,
firstUpperCase: firstUpperCase,

@@ -69,2 +71,26 @@ firstLowerCase: firstLowerCase

function deepExtend(self, obj, onlyEnumerable) {
return _extendTree(self, obj, onlyEnumerable, []);
}
function _extendTree(selfNode, objNode, onlyEnumerable, objTraversed) {
if (objTraversed.indexOf(objNode) >= 0) return; // node already traversed
objTraversed.push(objNode);
_.eachKey(objNode, function(value, prop) {
var descriptor = Object.getOwnPropertyDescriptor(objNode, prop);
if (typeof value == 'object') {
if (selfNode.hasOwnProperty(prop) && typeof selfNode[prop] == 'object')
_extendTree(selfNode[prop], value, onlyEnumerable, objTraversed)
else
Object.defineProperty(selfNode, prop, descriptor);
} else
Object.defineProperty(selfNode, prop, descriptor);
}, this, onlyEnumerable);
return selfNode;
}
function clone(obj) {

@@ -90,9 +116,3 @@ var clonedObject = Object.create(obj.constructor.prototype);

// pprototype chain
subclass.prototype = Object.create(thisClass.prototype);
// subclass identity
_.extendProto(subclass, {
constructor: subclass
});
_.makeSubclass(subclass, thisClass);

@@ -109,4 +129,9 @@ // copy class methods

function makeSubclass(thisClass, Superclass) {
// prototype chain
thisClass.prototype = Object.create(Superclass.prototype);
thisClass.prototype.constructor = thisClass;
// subclass identity
_.extendProto(thisClass, {
constructor: thisClass
});
return thisClass;

@@ -188,2 +213,12 @@ }

function toArray(arrayLike) {
var arr = [];
Array.prototype.forEach.call(arrayLike, function(item) {
arr.push(item)
});
return arr;
}
function firstUpperCase(str) {

@@ -190,0 +225,0 @@ return str[0].toUpperCase() + str.slice(1);

4

package.json
{
"name": "mol-proto",
"version": "0.0.2",
"description": "Prototypes aware object manipulation library for browser",
"version": "0.0.4",
"description": "Prototypes aware object manipulation library for node and modern browsers",
"main": "lib/proto.js",

@@ -6,0 +6,0 @@ "scripts": {

@@ -6,2 +6,4 @@ proto

[![Build Status](https://travis-ci.org/MailOnline/proto.png?branch=master)](https://travis-ci.org/MailOnline/proto)
Why not use underscore or lo-dash

@@ -8,0 +10,0 @@ ---------------------------------

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc