Comparing version 0.1.0 to 0.1.1
34
index.js
var extend = function(object, methodName, method) { | ||
Object.defineProperty(object.prototype, methodName, { | ||
enumerable: false, | ||
value: method | ||
}); | ||
if (!object.prototype[methodName]) { | ||
Object.defineProperty(object.prototype, methodName, { | ||
enumerable: false, | ||
value: method | ||
}); | ||
} | ||
}; | ||
extend(Array, "bsearch", function(v) { | ||
var arr = this | ||
, hi = arr.length - 1 | ||
, lo = 0 | ||
, pos; | ||
while (lo <= hi) { | ||
pos = (hi - lo)/2 + lo; | ||
pos = parseInt(pos); | ||
if (arr[pos] > v) { | ||
hi = pos - 1; | ||
} else if (arr[pos] < v) { | ||
lo = pos + 1; | ||
} else { | ||
return pos; | ||
} | ||
} | ||
return -1; | ||
}); | ||
extend(Array, "unique", function() { | ||
@@ -18,2 +40,6 @@ for (var i = 1; i < this.length; ++i) { | ||
extend(Array, "last", function() { | ||
return this[this.length - 1]; | ||
}); | ||
extend(Object, "join", function(object) { | ||
@@ -20,0 +46,0 @@ var objectA = object |
@@ -5,3 +5,3 @@ { | ||
"author": "Adam Blackburn <adam@ifit.com>", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"main": "index.js", | ||
@@ -8,0 +8,0 @@ "keywords": ["goodies", "merge", "unique", "unixtime"], |
@@ -21,2 +21,8 @@ # Goodies | ||
### `Array.bsearch(value)` | ||
This method only works on sorted arrays. | ||
It performs binary search on the array and searches for | ||
`value` and returns the index of value if found, or -1 if not found. | ||
### `Date.unixTime()` | ||
@@ -23,0 +29,0 @@ |
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
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
4238
68
40