object-manipulation
Advanced tools
Comparing version 1.0.6 to 1.1.0
28
index.js
@@ -54,6 +54,3 @@ class ObjectManager{} | ||
ObjectManager.passNew = function(obj1, obj2){ | ||
console.log('1', obj1); | ||
console.log('2', obj2); | ||
var diff = this.getDiffList(obj1, obj2); | ||
console.log('diff', diff); | ||
@@ -123,3 +120,3 @@ var output = {}; | ||
ObjectManager.merg = function (obj1, obj2, recursive = true){ | ||
ObjectManager.merge = function (obj1, obj2, recursive = true){ | ||
if (typeof(obj1) != "object"){ | ||
@@ -134,3 +131,3 @@ obj1 = {}; | ||
if (typeof(obj2[attrname]) == 'object' && typeof(obj1[attrname])){ | ||
obj1[attrname] = module.exports.merg(obj1[attrname], obj2[attrname]); | ||
obj1[attrname] = module.exports.merge(obj1[attrname], obj2[attrname]); | ||
}else{ | ||
@@ -168,2 +165,23 @@ if (typeof(obj2[attrname]) != 'undefined'){ | ||
ObjectManager.indexesOf = function(string, search){ | ||
var lastIndex = 0; | ||
var indexes = []; | ||
var searching = true; | ||
var loopNum = 0; | ||
while (loopNum<string.length) { | ||
var index = string.substr(lastIndex, string.length).indexOf(search); | ||
if (index == -1){ | ||
loopNum = string.length; | ||
}else{ | ||
lastIndex += index+1; | ||
indexes.push(lastIndex-1); | ||
} | ||
loopNum += 1; | ||
} | ||
return indexes; | ||
} | ||
module.exports = ObjectManager; |
{ | ||
"name": "object-manipulation", | ||
"version": "1.0.6", | ||
"version": "1.1.0", | ||
"description": "nodejs object manipulation library", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
A quick and easy object manipulation library. | ||
##ObjectManager.getDiffList(obj1, obj2, skipableRecursive) | ||
# Object manipulators / interpreters | ||
## getDiffList(obj1, obj2, skipableRecursive) | ||
obj1, and obj2, must be objects | ||
@@ -14,27 +15,30 @@ skipableRecursive must be either a boolean or undefined | ||
##ObjectManager.passNew(obj1, obj2, skipableRecursive) | ||
## passNew(obj1, obj2, skipableRecursive) | ||
Similar to getDiffList, but it will pass a object of which is only the new items | ||
##ObjectManager.merg(obj1, obj2, recursive) | ||
Will run though the two objects and merg objects 1 & 2 with 2 overwriting | ||
## merge(obj1, obj2, recursive) | ||
Will run though the two objects and merge objects 1 & 2 with 2 overwriting | ||
object 1 where necessary. | ||
recursive is default true | ||
## firstUndefined(array) | ||
This will return the first undefined value's index within an array | ||
## indexesOf(stirng, search) | ||
This will return an array of all indexes of the search term within the string | ||
##ObjectManager.isFunction(item) | ||
___ | ||
# Other functions | ||
## isFunction(item) | ||
Will parse a boolean on whether item is a function or not | ||
##ObjectManager.isObject(item) | ||
## isObject(item) | ||
Will parse a boolean on whether item is a object {} or not | ||
##ObjectManager.isArray(item) | ||
## isArray(item) | ||
Will parse a boolean on whether item is a array [] or not |
6154
158
44