Travis build: 2114 [cron]

This commit is contained in:
30secondsofcode
2018-05-31 21:18:41 +00:00
parent 91d9546169
commit 19d7818ae6
5 changed files with 64 additions and 24 deletions

File diff suppressed because one or more lines are too long

View File

@ -5399,6 +5399,26 @@
"hash": "c1fec7508780ad0ceacbf58c049668201e9f88eee043234394e11666530cfb21" "hash": "c1fec7508780ad0ceacbf58c049668201e9f88eee043234394e11666530cfb21"
} }
}, },
{
"id": "toHash",
"type": "snippet",
"attributes": {
"fileName": "toHash.md",
"text": "Reduces a given Array-like into a value hash (keyed data store).\n\nGiven an Iterable or Array-like structure, call `Array.prototype.reduce.call()` on the provided object to step over it and return an Object, keyed by the reference value.",
"codeBlocks": [
"const toHash = (object, key) =>\n Array.prototype.reduce.call(\n object,\n (acc, data, index) => ((acc[!key ? index : data[key]] = data), acc),\n {}\n );",
"toHash([4, 3, 2, 1]); // { 0: 4, 1: 3, 2: 2, 1: 1 }\ntoHash([{ a: 'label' }], 'a'); // { label: { a: 'label' } }\n// A more in depth example:\nlet users = [{ id: 1, first: 'Jon' }, { id: 2, first: 'Joe' }, { id: 3, first: 'Moe' }];\nlet managers = [{ manager: 1, employees: [2, 3] }];\n// We use function here because we want a bindable reference, but a closure referencing the hash would work, too.\nmanagers.forEach(\n manager =>\n (manager.employees = manager.employees.map(function(id) {\n return this[id];\n }, toHash(users, 'id')))\n);\nmanagers; // [ { manager:1, employees: [ { id: 2, first: \"Joe\" }, { id: 3, first: \"Moe\" } ] } ]"
],
"tags": [
"array",
"object"
]
},
"meta": {
"archived": false,
"hash": "c7a62b55b5a90661bf3f9c956f075906439a50151a3aee4023ad8fe878cae2e6"
}
},
{ {
"id": "toKebabCase", "id": "toKebabCase",
"type": "snippet", "type": "snippet",

View File

@ -1,4 +1,4 @@
Test log for: Wed May 30 2018 21:16:49 GMT+0000 (UTC) Test log for: Thu May 31 2018 21:18:33 GMT+0000 (UTC)
> 30-seconds-of-code@0.0.3 test /home/travis/build/Chalarangelo/30-seconds-of-code > 30-seconds-of-code@0.0.3 test /home/travis/build/Chalarangelo/30-seconds-of-code
> tape test/**/*.test.js | tap-spec > tape test/**/*.test.js | tap-spec
@ -1765,6 +1765,10 @@ Test log for: Wed May 30 2018 21:16:49 GMT+0000 (UTC)
✔ toDecimalMark is a Function ✔ toDecimalMark is a Function
✔ convert a float-point arithmetic to the Decimal mark form ✔ convert a float-point arithmetic to the Decimal mark form
Testing toHash
✔ toHash is a Function
Testing toKebabCase Testing toKebabCase
✔ toKebabCase is a Function ✔ toKebabCase is a Function
@ -2041,10 +2045,10 @@ Test log for: Wed May 30 2018 21:16:49 GMT+0000 (UTC)
✖ currency: Japanese Yen | currencyLangFormat: Local ✖ currency: Japanese Yen | currencyLangFormat: Local
total: 1021 total: 1022
passing: 1019 passing: 1020
failing: 2 failing: 2
duration: 2.3s duration: 2.5s
undefined undefined

7
test/toHash/toHash.js Normal file
View File

@ -0,0 +1,7 @@
const toHash = (object, key) =>
Array.prototype.reduce.call(
object,
(acc, data, index) => ((acc[!key ? index : data[key]] = data), acc),
{}
);
module.exports = toHash;

View File

@ -0,0 +1,13 @@
const test = require('tape');
const toHash = require('./toHash.js');
test('Testing toHash', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof toHash === 'function', 'toHash is a Function');
//t.deepEqual(toHash(args..), 'Expected');
//t.equal(toHash(args..), 'Expected');
//t.false(toHash(args..), 'Expected');
//t.throws(toHash(args..), 'Expected');
t.end();
});