File tree Expand file tree Collapse file tree 3 files changed +14
-1
lines changed
Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 1+ - Add tag for a minor/major release by ` npm version minor ` and ` npm version major ` after commit
Original file line number Diff line number Diff line change 11{
22 "name" : " @stackbox-dev/stdlib" ,
3- "version" : " 2.1.0 " ,
3+ "version" : " 2.1.1 " ,
44 "description" : " Node.js Standary Utility Functions" ,
55 "main" : " dist/index.js" ,
66 "repository" : {
Original file line number Diff line number Diff line change @@ -64,6 +64,18 @@ export const unique = <T>(items: T[]): T[] => {
6464 return resp ;
6565} ;
6666
67+ export const uniqueBy = < T > ( items : T [ ] , fn : KeyFn < T > ) : T [ ] => {
68+ const seen = new Set < string | number > ( ) ;
69+ const resp : T [ ] = [ ] ;
70+ for ( const item of items ) {
71+ const value = fn ( item ) ;
72+ if ( seen . has ( value ) ) continue ;
73+ resp . push ( item ) ;
74+ seen . add ( value ) ;
75+ }
76+ return resp ;
77+ } ;
78+
6779export const intersection = < T > ( items1 : T [ ] , items2 : T [ ] ) => {
6880 const items2Set = new Set ( items2 ) ;
6981 const inters = new Set < T > ( ) ;
You can’t perform that action at this time.
0 commit comments