_.map(resources, (resource, idx) => { let format = msg.body.resourceFormat[idx]; if (format == 'serialized') return compileDefinition(resource); return resource; })
describe('createChildren()', function() { it('should create module actor children from a specified directory', async function () { let childActors = await rootActor.createChildren('/test-resources/actors/child-actors', { mode: 'forked' }); expect(childActors.length).to.be.equal(2); let childActorNames = _.map(childActors, (actor: ActorRef) => actor.getName()); expect(childActorNames).to.have.members(['ChildActor1', 'ChildActor2']); let childActorReplies = await P.map(childActors, (actor: ActorRef) => actor.sendAndReceive('hello')); expect(childActorReplies).to.have.members(['Hello from ChildActor1', 'Hello from ChildActor2']); }); });
function sendReleaseLock(conn, userLocks) { sendData(conn, {type: "releaseLock", locks: _.map(userLocks, function(e) { return { block: e.block, user: e.user, time: Date.now(), changes: null }; })}); }
/* Maps keys (instead of values) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ _.withTest (['stdlib', 'mapKeys'], function () { $assert (_.mapKeys ({ 'foo': [1, 2,{ 'gay': 3 }]}, _.appends ('bar')), { 'foobar': [1, 2,{ 'gaybar': 3 }]}) }, function () { _.mapKeys = function (x, fn) { if (_.isArrayLike (x)) { return _.map (x, _.tails2 (_.mapKeys, fn)) } else if (_.isStrictlyObject (x)) { return _.fromPairs (_.map (O.entries (x), function (kv) { return [fn (kv[0]), _.mapKeys (kv[1], fn)] })) } else { return x } } })
// Since Jasmine 1.3 does not have afterAll callback, this disconnect test must be last it('disconnects client', function(done) { // Guarantee that even if one of the disconnect fails, all disconnects have been called Promise.all([client, client1, client2, client3]) .then(function(clients) { return Promise.all(_.map(clients, function(client) { return client.disconnect(); })); }) .catch(t.failed(done)) .finally(done); });
test("initial", function() { equal(_.initial([1,2,3,4,5]).join(", "), "1, 2, 3, 4", 'working initial()'); equal(_.initial([1,2,3,4],2).join(", "), "1, 2", 'initial can take an index'); var result = (function(){ return _(arguments).initial(); })(1, 2, 3, 4); equal(result.join(", "), "1, 2, 3", 'initial works on arguments object'); result = _.map([[1,2,3],[1,2,3]], _.initial); equal(_.flatten(result).join(','), '1,2,1,2', 'initial works with _.map'); });
r.db('nakiva').table('companies').run().then(function(data) { var orgsList; orgsList = _.map(data[0].orgs, function(orgData) { return { logo: orgData.logo, name: orgData.name, id: orgData.id }; }); callback(orgsList); });
report (state = {}) { const { indent = 0, prevLocations = [] } = state const supressRedundantNesting = (this.eventLog.length === 1) && (this.eventLog[0] instanceof AndrogeneProcessContext) const head = this.reportLocation (state) const body = this.reportContents (O.assign ({}, state, { indent: indent + (((head.length === 0) || supressRedundantNesting) ? 0 : 1), prevLocations: new Set ([...prevLocations, ..._.map (head, m => locationId (m.data.where))]) })) return (state.verbose || (body.length > 0)) ? [...head, ...body] : [] }
function sslSocketOpts(sslOpts, reject) { var options = {}; options.ca = _.map(sslOpts.trustCerts, function (cert) { return fs.readFileSync(cert); }); options = sslClientAuthOpts(options, sslOpts.clientAuth); options = sslCryptoStoreOpts(options, sslOpts.cryptoStore, reject); options.secureProtocol = sslOpts.secureProtocol; options.servername = sslOpts.sniHostName; return options; }
it('can iterate over entries getting their expirable metadata', function (done) { var pairs = [{key: 'it-exp-1', value: 'v1'}, {key: 'it-exp-2', value: 'v2'}]; var expected = _.map(pairs, function (pair) { return f.merge(pair, {done: false, lifespan: 86400, maxIdle: 3600}); }); client .then(t.assert(t.clear())) .then(t.assert(t.putAll(pairs, {lifespan: '1d', maxIdle: '1h'}), t.toBeUndefined)) .then(t.seqIterator('key', 3, expected, {metadata: true})) // Iterate all data, 3 elements at time, sequential .catch(t.failed(done)) .finally(done); });
then (resolve, reject) { var next = this.processContext.within (OriginalPromise.prototype.then, 2).apply (this, // @hide _.map (arguments, function (fn) { return fn && (function (x) { return next.processContext.within (fn, -3) (x) }) })) // @hide return next }
// Iterates through a list of events, and converts each returned value to a Date // type object, and builds it in a format that BigCalendar can parse const mapEvents = (events) => { return _.map(events, (ev) => { return { "title": ev.plan_details, "start": moment(ev.plan_start_datetime).toDate(), "end": moment(ev.plan_end_datetime).toDate(), } }) }
test("rest", function() { var numbers = [1, 2, 3, 4]; equal(_.rest(numbers).join(", "), "2, 3, 4", 'working rest()'); equal(_.rest(numbers, 0).join(", "), "1, 2, 3, 4", 'working rest(0)'); equal(_.rest(numbers, 2).join(', '), '3, 4', 'rest can take an index'); var result = (function(){ return _(arguments).tail(); })(1, 2, 3, 4); equal(result.join(', '), '2, 3, 4', 'aliased as tail and works on arguments object'); result = _.map([[1,2,3],[1,2,3]], _.rest); equal(_.flatten(result).join(','), '2,3,2,3', 'works well with _.map'); result = (function(){ return _(arguments).drop(); })(1, 2, 3, 4); equal(result.join(', '), '2, 3, 4', 'aliased as drop and works on arguments object'); });
setCookies (cookies) { return _.extend2 (this, { cookies: cookies, headers: { 'Set-Cookie': _.map (cookies, (value, name) => name + '=' + (value || '<<deleted>>') + '; Expires=Wed, 13-Jan-2100 22:23:01 GMT; Path=/') } } ) }
describe('createChildren()', function() { it('should create module actor children from a specified directory', async () => { let childActors = await rootActor.createChildren( '/test-resources/actors/child-actors', { mode: 'remote', host: '127.0.0.1' }); expect(childActors.length).to.be.equal(2); let childActorNames = _.map(childActors, actor => actor.getName()); expect(childActorNames).to.have.members(['ChildActor1', 'ChildActor2']); let childActorReplies = await P.map(childActors, actor => actor.sendAndReceive('hello')); expect(childActorReplies).to.have.members(['Hello from ChildActor1', 'Hello from ChildActor2']); }); });