Skip to content

Commit

Permalink
Lodash: Remove completely from token-list package (#41864)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla authored Jun 22, 2022
1 parent c3213b1 commit e542907
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/token-list/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"react-native": "src/index",
"types": "build-types",
"dependencies": {
"@babel/runtime": "^7.16.0",
"lodash": "^4.17.21"
"@babel/runtime": "^7.16.0"
},
"publishConfig": {
"access": "public"
Expand Down
13 changes: 6 additions & 7 deletions packages/token-list/src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { uniq, compact, without } from 'lodash';

/**
* A set of tokens.
*
Expand Down Expand Up @@ -75,7 +70,9 @@ export default class TokenList {
*/
set value( value ) {
value = String( value );
this._valueAsArray = uniq( compact( value.split( /\s+/g ) ) );
this._valueAsArray = [
...new Set( value.split( /\s+/g ).filter( Boolean ) ),
];
this._currentValue = this._valueAsArray.join( ' ' );
}

Expand Down Expand Up @@ -158,7 +155,9 @@ export default class TokenList {
* @param {...string} items Items to remove.
*/
remove( ...items ) {
this.value = without( this._valueAsArray, ...items ).join( ' ' );
this.value = this._valueAsArray
.filter( ( val ) => ! items.includes( val ) )
.join( ' ' );
}

/**
Expand Down

0 comments on commit e542907

Please sign in to comment.