From f6b60e428f2089a458cb6d9e148adebc04fa6d4f Mon Sep 17 00:00:00 2001 From: Eric Cornelissen Date: Fri, 28 May 2021 12:16:50 +0200 Subject: [PATCH] Rename 'get' to 'Get' on simpleIcons export (#5777) --- README.md | 6 +++--- scripts/build/templates/index.js | 9 ++++++++- tests/index.test.js | 10 +++++++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2c6ca9590..f0f0eae6c 100644 --- a/README.md +++ b/README.md @@ -51,10 +51,10 @@ The API can then be used as follows, where `[ICON SLUG]` is replaced by a [slug] const simpleIcons = require('simple-icons'); // Get a specific icon by its slug as: -simpleIcons.get('[ICON SLUG]'); +simpleIcons.Get('[ICON SLUG]'); // For example: -const icon = simpleIcons.get('simpleicons'); +const icon = simpleIcons.Get('simpleicons'); ``` @@ -102,7 +102,7 @@ This is useful if you want to do a computation on every icon: const simpleIcons = require('simple-icons'); for (const title in simpleIcons) { - const icon = simpleIcons.get(title); + const icon = simpleIcons.Get(title); // do stuff } ``` diff --git a/scripts/build/templates/index.js b/scripts/build/templates/index.js index e44ae7536..6038995dc 100644 --- a/scripts/build/templates/index.js +++ b/scripts/build/templates/index.js @@ -1,10 +1,17 @@ var icons = {%s}; -Object.defineProperty(icons, "get", { +Object.defineProperty(icons, "Get", { enumerable: false, value: function(targetName) { return icons[targetName]; } }); +Object.defineProperty(icons, "get", { + enumerable: false, + value: function(targetName) { + return this.Get(targetName); + } +}); + module.exports = icons; diff --git a/tests/index.test.js b/tests/index.test.js index 3410d0418..88d86e776 100644 --- a/tests/index.test.js +++ b/tests/index.test.js @@ -59,7 +59,15 @@ icons.forEach(icon => { } }); - test(`${icon.title} can be found by it's slug`, () => { + test(`'Get' ${icon.title} by its slug`, () => { + const found = simpleIcons.Get(slug); + expect(found).toBeDefined(); + expect(found.title).toEqual(icon.title); + expect(found.hex).toEqual(icon.hex); + expect(found.source).toEqual(icon.source); + }); + + test(`'get' ${icon.title} by its slug`, () => { const found = simpleIcons.get(slug); expect(found).toBeDefined(); expect(found.title).toEqual(icon.title);