UNPKG

burn

Version:

Super lightweight JS module/asset loader

33 lines (30 loc) 845 B
/* * String formatting helper */ if ( !String.prototype.format ) { var util = require('util'); String.prototype.format = function() { // construct new arguments list to format var args = Array.prototype.slice.call(arguments); var newargs = [this.toString(), ].concat(args) return util.format.apply(this, newargs); }; } /* * This is because String.replace() has some * weird regex magic which is not only slow * but also corrupts our output on special chars * such as $.... FUCKING JS. */ if ( !String.prototype.replaceAll ) { String.prototype.replaceAll = function(search, replace) { return this.toString().split(search).join(replace); }; } module.exports = { each: function(obj, cb) { Object.keys(obj).forEach(function(name) { cb(name, obj[name]); }); } }