Skip to content

Commit

Permalink
deprecate index (#7453)
Browse files Browse the repository at this point in the history
  • Loading branch information
sachinraja committed May 27, 2022
1 parent 665b825 commit 986589c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 26 deletions.
27 changes: 1 addition & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 <img src="https://raw.githubusercontent.com/simple-icons/simple-icons/develop/icons/typescript.svg#gh-light-mode-only" alt="Typescript" align=left width=19 height=19><img src="https://raw.githubusercontent.com/simple-icons/simple-icons/develop/assets/readme/typescript-white.svg#gh-dark-mode-only" alt="Typescript" align=left width=19 height=19>

Type definitions are bundled with the package.
Expand Down
3 changes: 3 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, SimpleIcon> & {
Get(name: string): SimpleIcon;
};
Expand Down
2 changes: 2 additions & 0 deletions scripts/build/templates/index.js
Original file line number Diff line number Diff line change
@@ -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", {
Expand Down

0 comments on commit 986589c

Please sign in to comment.