mirror of
https://github.com/simple-icons/simple-icons.git
synced 2024-12-16 01:10:30 +02:00
Rename 'get' to 'Get' on simpleIcons export (#5777)
This commit is contained in:
parent
8d21b9910b
commit
f6b60e428f
@ -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
|
||||
}
|
||||
```
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user