1
0
mirror of https://github.com/simple-icons/simple-icons.git synced 2025-01-25 01:32:58 +02:00

deprecate index (#7453)

This commit is contained in:
Sachin Raja 2022-05-26 23:18:44 -07:00 committed by GitHub
parent 665b82590d
commit 986589c34c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 26 deletions

View File

@ -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 <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.

3
index.d.ts vendored
View File

@ -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;
};

View File

@ -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", {