From 6470bf8be2a18e9979144e2fa5f5f4906d4e2897 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Fri, 26 Mar 2021 17:04:57 +0100 Subject: [PATCH] Update dev-dependencies --- package.json | 2 +- script/build-data.js | 22 ++++++++++++++-------- test.js | 24 ++++++++++++++++-------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 36928ba..442ed99 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "remark-preset-wooorm": "^8.0.0", "tape": "^5.0.0", "tinyify": "^3.0.0", - "xo": "^0.37.0" + "xo": "^0.38.0" }, "scripts": { "generate": "node script/build-data", diff --git a/script/build-data.js b/script/build-data.js index 0fa15db..b60aee1 100644 --- a/script/build-data.js +++ b/script/build-data.js @@ -62,9 +62,11 @@ var data = Object.keys(schema) // Detect if emoticons are classified multiple times. var known = {} +var info +var emoticon -data.forEach(function (info) { - info.emoticons.forEach(function (emoticon) { +for (info of data) { + for (emoticon of info.emoticons) { if (own.call(known, emoticon)) { console.log( 'Duplicate emoticon `%s` in `%s` and `%s`', @@ -75,19 +77,23 @@ data.forEach(function (info) { } known[emoticon] = info.name - }) -}) + } +} // Write. fs.writeFileSync('index.json', JSON.stringify(data, null, 2) + '\n') function unpack(value) { var result = [] - value[0].forEach(function (first) { - value[1].forEach(function (second) { + var first + var second + + for (first of value[0]) { + for (second of value[1]) { result.push(first + second) - }) - }) + } + } + return result } diff --git a/test.js b/test.js index aeded88..ded3ede 100644 --- a/test.js +++ b/test.js @@ -8,31 +8,39 @@ test('emoticon', function (t) { t.ok(Array.isArray(emoticon), 'should be an array') t.doesNotThrow(function () { - emoticon.forEach(function (info) { + var info + + for (info of emoticon) { assert.strictEqual(typeof info.emoji, 'string', JSON.stringify(info)) - }) + } }, 'each entry should have an `emoji` string field') t.doesNotThrow(function () { - emoticon.forEach(function (info) { + var info + + for (info of emoticon) { assert.strictEqual( typeof info.description, 'string', JSON.stringify(info) ) - }) + } }, 'each entry should have an `description` string field') t.doesNotThrow(function () { - emoticon.forEach(function (info) { + var info + + for (info of emoticon) { assert.ok(Array.isArray(info.tags), JSON.stringify(info)) - }) + } }, 'each entry should have an `tags` array field') t.doesNotThrow(function () { - emoticon.forEach(function (info) { + var info + + for (info of emoticon) { assert.ok(Array.isArray(info.emoticons), JSON.stringify(info)) - }) + } }, 'each entry should have an `emoticons` array field') t.end()