@aaronragudos/javascriptfilter

1.0.0 • Public • Published
��# J a v a s c r i p t F i l t e r # # H e l l o ! T h i s l i b r a r y o r s o u r c e c o d e i s w r i t t e n i n T y p e S c r i p t ( I ' m n e w t o T S , s o i t w o u l d b e m y p l e a s u r e t o w o r k w i t h y o u i f y o u w a n t t o r e f a c t o r m y c o d e . ) , a n d t h e f u n c t i o n s t h i s f i l t e r p r o v i d e s a r e : # # # 1 . s o r t D a t a ( ) # # # # - s o r t D a t a ( ) a c c e p t s o n e a r g u m e n t , b u t t h a t a r g u m e n t s h o u l d b e a n o b j e c t { } t h a t c o n t a i n s t h r e e v a l u e s / v a r i a b l e s : # # # # # a . T h e r a w d a t a i t s e l f t h a t y o u w a n t t o f i l t e r . # # # # # b . T h e c h a r a c t e r i s t i c s / t r a i t s o f e a c h o b j e c t o f t h e r a w d a t a y o u w a n t t o f i l t e r ( e . g . A r a w d a t a o f [ { n a m e : ' A a r o n ' , c h a r a c t e r i s t i c s : [ ' c h a r i s m a t i c ' , ' p a s s i o n a t e ' ] } , { n a m e : ' A n g e l ' , c h a r a c t e r i s t i c s : [ ' c l e v e r ' , ' e n t h u s i a s t i c ' ] } ] w i l l h a v e t h e s e c o n d d a t a t u r n e d i n t o [ [ ' c h a r i s m a t i c ' , ' p a s s i o n a t e ' ] , [ ' c l e v e r ' , ' e n t h u s i a s t i c ] ] ) ; # # # # N O T E : Y o u n e e d t o d o t h i s y o u r s e l f a s I d o n o t k n o w o f a w a y t o t a r g e t a v a r i a b l e f r o m a n o b j e c t w i t h o u t k n o w i n g s i t s n a m e . # # # # c . T h e t h i r d d a t a i s t h e p r e f e r e n c e s y o u w a n t o r t h e w a n t s o f y o u r u s e r s . ( e . g . [ ' f u n n y ' , ' c h a r i s m a t i c ' , ' e n t h u s i a s t i c ' ] ) ; # # # # T h i s r e t u r n s a l l t h e d a t a t h a t h a d a m a t c h o f c h a r a c t e r i s t i c s w i t h t h e p r e f e r e n c e s a t l e a s t o n c e . # # # 2 . g e t P e r c e n t a g e O c c u r e n c e ( ) # # # # - g e t P e r c e n t a g e O c c u r e n c e ( ) i s t h e s a m e a s s o r t D a t a ( ) , h o w e v e r , t h i s f u n c t i o n r e t u r n s n o t o n l y t h e f i l t e r e d d a t a , b u t a l s o t h e p e r c e n t a g e a n d d e c i m a l v a l u e o f t h e r a t e o f m a t c h e a c h o b j e c t ' s c h a r a c t e r i s t i c s / t r a i t s w i t h t h e p r e f e r e n c e s . # # D e m o # # # C u r r e n t l y b e i n g b u i l t

Package Sidebar

Install

npm i @aaronragudos/javascriptfilter

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

36.8 kB

Total Files

16

Last publish

Collaborators

  • aaronragudos