Comparing version 0.4.1 to 0.4.2
{ | ||
"name": "wodge", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "a wodge of functional dough", | ||
@@ -5,0 +5,0 @@ "main": "wodge.js", |
68
wodge.js
"use strict"; | ||
/** @module wodge */ | ||
var util = require("util"); | ||
@@ -24,2 +25,3 @@ | ||
exports.without = without; | ||
exports.first = first; | ||
@@ -35,3 +37,3 @@ function extend(){ | ||
}, {}); | ||
}; | ||
} | ||
@@ -44,3 +46,3 @@ function clone(obj){ | ||
return output; | ||
}; | ||
} | ||
@@ -54,3 +56,3 @@ function omit(obj, toOmit){ | ||
return output; | ||
}; | ||
} | ||
@@ -60,3 +62,3 @@ /** | ||
@method | ||
@example | ||
@example | ||
w.escapeRegExp("(.*)"); // => '\\(\\.\\*\\)' | ||
@@ -68,3 +70,3 @@ */ | ||
: ""; | ||
}; | ||
} | ||
@@ -88,10 +90,10 @@ /** | ||
return output; | ||
}; | ||
} | ||
function isNumber(n){ | ||
return !isNaN(parseFloat(n)) && isFinite(n); | ||
}; | ||
} | ||
function isPlainObject(o){ | ||
return typeof o === "object" && !Array.isArray(o); | ||
}; | ||
} | ||
@@ -106,11 +108,11 @@ function arrayify(arr){ | ||
} | ||
}; | ||
} | ||
function every(obj, callback){ | ||
var every = true; | ||
var ev = true; | ||
for (var prop in obj){ | ||
every = every && callback(obj[prop], prop); | ||
ev = ev && callback(obj[prop], prop); | ||
} | ||
return every; | ||
}; | ||
return ev; | ||
} | ||
@@ -121,3 +123,3 @@ function each(obj, callback){ | ||
} | ||
}; | ||
} | ||
@@ -131,25 +133,23 @@ function bytesToSize(bytes, precision){ | ||
if ((bytes >= 0) && (bytes < kilobyte)) { | ||
return bytes + ' B'; | ||
return bytes + " B"; | ||
} else if ((bytes >= kilobyte) && (bytes < megabyte)) { | ||
return (bytes / kilobyte).toFixed(precision) + ' KB'; | ||
return (bytes / kilobyte).toFixed(precision) + " KB"; | ||
} else if ((bytes >= megabyte) && (bytes < gigabyte)) { | ||
return (bytes / megabyte).toFixed(precision) + ' MB'; | ||
return (bytes / megabyte).toFixed(precision) + " MB"; | ||
} else if ((bytes >= gigabyte) && (bytes < terabyte)) { | ||
return (bytes / gigabyte).toFixed(precision) + ' GB'; | ||
return (bytes / gigabyte).toFixed(precision) + " GB"; | ||
} else if (bytes >= terabyte) { | ||
return (bytes / terabyte).toFixed(precision) + ' TB'; | ||
return (bytes / terabyte).toFixed(precision) + " TB"; | ||
} else { | ||
return bytes + ' B'; | ||
return bytes + " B"; | ||
} | ||
}; | ||
} | ||
function getHomeDir() { | ||
return process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE; | ||
}; | ||
return process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE; | ||
} | ||
function fill(fillWith, len){ | ||
@@ -159,4 +159,3 @@ var buffer = new Buffer(len); | ||
return buffer.toString(); | ||
}; | ||
} | ||
function padRight(input, width, padWith){ | ||
@@ -169,3 +168,3 @@ padWith = padWith || " "; | ||
} | ||
}; | ||
} | ||
@@ -181,2 +180,13 @@ function exists(arr, value){ | ||
}); | ||
}; | ||
} | ||
/** | ||
Works on an array of objects. Returns the first object with `property` set to `value`. | ||
@alias module:wodge.first | ||
*/ | ||
function first(arr, prop, val){ | ||
var result = arr.filter(function(item){ | ||
return item[prop] ? item[prop] === val : false; | ||
}); | ||
return result ? result[0] : null; | ||
} |
Sorry, the diff of this file is not supported yet
5733
177