From 986589c34c1224fcd0244e07a8fe833079fd836f Mon Sep 17 00:00:00 2001 From: Sachin Raja Date: Thu, 26 May 2022 23:18:44 -0700 Subject: [PATCH] deprecate index (#7453) --- README.md | 27 +-------------------------- index.d.ts | 3 +++ scripts/build/templates/index.js | 2 ++ 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 6d646cc6d..c0d053fd3 100644 --- a/README.md +++ b/README.md @@ -49,20 +49,7 @@ The icons are also available through our npm package. To install, simply run: npm install simple-icons ``` -The API can then be used as follows, where `[ICON SLUG]` is replaced by a [slug]: - -```javascript -const simpleIcons = require('simple-icons'); - -// Get a specific icon by its slug as: -// simpleIcons.Get('[ICON SLUG]'); - -// For example: -const icon = simpleIcons.Get('simpleicons'); - -``` - -Alternatively, you can also import all icons from a single file, where `[ICON SLUG]` is replaced by a capitalized [slug]. We highly recommend using a bundler that can tree shake such as [webpack](https://webpack.js.org/) to remove the unused icon code: +All icons are imported from a single file, where `[ICON SLUG]` is replaced by a capitalized [slug]. We highly recommend using a bundler that can tree shake such as [webpack](https://webpack.js.org/) to remove the unused icon code: ```javascript // Import a specific icon by its slug as: // import { si[ICON SLUG] } from 'simple-icons/icons' @@ -99,18 +86,6 @@ NOTE: the `license` entry will be `undefined` if we do not yet have license data */ ``` -Lastly, the `simpleIcons` object is also enumerable. -This is useful if you want to do a computation on every icon: - -```javascript -const simpleIcons = require('simple-icons'); - -for (const iconSlug in simpleIcons) { - const icon = simpleIcons.Get(iconSlug); - // do stuff -} -``` - #### TypeScript Usage TypescriptTypescript Type definitions are bundled with the package. diff --git a/index.d.ts b/index.d.ts index 409df601e..314f6c336 100644 --- a/index.d.ts +++ b/index.d.ts @@ -14,6 +14,9 @@ export interface SimpleIcon { | undefined; } +/** + * @deprecated The `simple-icons` entrypoint will be removed in the next major. Please switch to using `import * as icons from "simple-icons/icons"` if you need an object with all the icons. + */ declare const icons: Record & { Get(name: string): SimpleIcon; }; diff --git a/scripts/build/templates/index.js b/scripts/build/templates/index.js index b627a4dd4..2b8c4341d 100644 --- a/scripts/build/templates/index.js +++ b/scripts/build/templates/index.js @@ -1,3 +1,5 @@ +console.warn('Deprecation warning: The `simple-icons` entrypoint will be removed in the next major. Please switch to using `import * as icons from "simple-icons/icons"` if you need an object with all the icons.') + var icons = {%s}; Object.defineProperty(icons, "Get", {