UNPKG

omljs

Version:

Template engine built on top of the Oli language

75 lines 1.75 kB
var hasOwn, toString, isBrowser, clone, isUndef, isString, isObject, isArray; hasOwn = Object.prototype.hasOwnProperty; toString = Object.prototype.toString; exports.isBrowser = isBrowser = typeof window !== 'undefined'; exports.cwd = function(){ if (isBrowser) { return '/'; } else { return process.cwd(); } }; exports.extend = function(target, origin){ var name, value, own$ = {}.hasOwnProperty; target == null && (target = {}); for (name in origin) if (own$.call(origin, name)) { value = origin[name]; target[name] = value; } return target; }; exports.clone = clone = function(it){ var target, name, value, own$ = {}.hasOwnProperty; target = {}; for (name in it) if (own$.call(it, name)) { value = it[name]; if (isArray( value)) { value = value.slice(); } else if (isObject( value)) { value = clone( value); } target[name] = value; } return target; }; exports.isUndef = isUndef = function(it){ return it === null || it === undefined; }; exports.isString = isString = function(it){ return typeof it === 'string'; }; exports.isObject = isObject = function(it){ return toString.call( it) === '[object Object]'; }; exports.isArray = isArray = function(it){ return toString.call( it) === '[object Array]'; }; exports.has = function(obj, prop){ if (!isUndef( obj)) { return hasOwn.call(obj, prop); } else { return false; } }; exports.isArrayStrings = function(it){ var i$, len$, item; for (i$ = 0, len$ = it.length; i$ < len$; ++i$) { item = it[i$]; if (!isString( item)) { return false; } } return true; }; exports.echo = function(){ if (console) { return console.log.apply(console, arguments); } };