map (obj, fn) { if (URIRouter.isCanonicalRoute (obj)) { return [fn (obj[1], obj[0])] } return _.map (obj, _.isArray (obj) ? function (route) { return fn (route[1], route[0]) } : fn) }
f.dispatch( function(s) { return !f.existy(s) ? 'undefined' : undefined }, function(s) { return _.isString(s) ? (s.length > 1024 ? s.substring(0, 1024) + '...' : s) : undefined}, function(s) { return _.isArray(s) ? stringifyArray(s) : undefined }, function(s) { return _.isObject(s) ? JSON.stringify(s) : undefined }, function(s) { return s.toString() })
function encodeDecode(size, encoder, decoder, bufferSize) { var enc = f.actions(_.isArray(encoder) ? encoder : [encoder], codec.bytesEncoded); var bytebuf = t.assertEncode(t.newByteBuf(bufferSize), enc, size); var dec = f.actions(_.isArray(decoder) ? decoder : [decoder], codec.allDecoded(decoder.length)); return dec({buf: bytebuf.buf, offset: 0}); }
var unifyType = function (value) { if (_.isArray (value)) { return _.nonempty ([_.reduce (value.slice (1), function (a, b) { return _.undiff (a, b) }, _.first (value) || undefined)]) } else if (_.isStrictlyObject (value)) { var pairs = _.pairs (value) var unite = _.map ( _.reduce (pairs.slice (1), function (a, b) { return _.undiff (a, b) }, _.first (pairs) || [undefined, undefined]), _.nonempty) return (_.isEmpty (unite) || _.isEmpty (unite[1])) ? value : _.fromPairs ([[unite[0] || '*', unite[1]]]) } else { return value } }
$static (function (arr) { return _.reduce ((_.isArray (arr) && arr) || _.asArray (arguments), function (memo, v) { return memo.add (v || Vec2.zero) }, Vec2.zero) })
function localizeShippingRegions(regions) { var localized = []; if (!__.isArray(regions)) { throw new Error('Please provide an array of country dataNames.'); } regions.forEach((region) => { if (region === 'ALL') { localized.push(window.polyglot.t('WorldwideShipping')); } else { localized.push(window.polyglot.t(`countries.${region}`)); } }); return localized; }
/* Fixes _.isArray to account objects that derive from Array prototype ======================================================================== */ _.deferTest (['type', 'isArray'], function () { var CustomArray = $extends (Array, { method: function () { return 42 } }) $assert (_.isArray (new CustomArray ())) }, function () { _.isArray = function (x) { return x instanceof Array } })
function normalizeAddresses(args) { var normalizer = f.dispatch( function(xs) { return _.isArray(xs) ? xs : undefined }, function(x) { return _.isObject(x) ? [x] : undefined }, function(x) { if (f.existy(x)) throw new Error('Unknown server addresses: ' + x); return [{port: 11222, host: '127.0.0.1'}] }); return normalizer(args); }
canonicalize (obj) { if (!obj) { return [] } else if (URIRouter.isFunctionOrChain (obj)) { return { get: obj } } else if (URIRouter.isHandler (obj)) { return obj } return URIRouter.map (obj, (value, key) => { var subpaths = key.split ('/') if (subpaths.length > 1) { return _.reduceRight (subpaths, (memo, path) => { return [path, _.isArray (memo) ? [memo] : memo] }, URIRouter.canonicalize (value)) } return [key, URIRouter.canonicalize (value)] }, this) }
/** * Creates new logger with configuration from given configuration file (or files). Changes in * configuration file(s) are applied immediately on the run. * * @param {String|String[]} path Path (or paths) to logger configuration file(s). * @param {String} [category='Default'] Logger category. * @returns {Logger} Logger instance. */ static fromConfigurationFile(path = [], category = 'Default') { let configuration; if (!_.isEmpty(path)) { configuration = LoggerConfiguration.fromFiles(_.isArray(path) ? path : [path], new Logger()); } return new Logger(undefined, category, configuration); }
function assert(expected, size, encoder, decoder, bufferSize) { var ret = encodeDecode(size, encoder, decoder, bufferSize); expect(ret).toEqual(_.isArray(expected) ? expected : [expected]); }
nm_.each(validators, function(validator) { if (!validator.validator(value, instance)) { if (!messages) { messages = []; } var message = validator.message(displayName); if (nm_.isArray(message)) { messages = messages.concat(message); } else { messages.push(message); } } });