Gathering detailed insights and metrics for simple-fns
Gathering detailed insights and metrics for simple-fns
Gathering detailed insights and metrics for simple-fns
Gathering detailed insights and metrics for simple-fns
vue3-datepicker
A simple Vue 3 datepicker component. Supports disabling of dates, translations. Dependent on date-fns.
simple-helper-fns
lithen-fns
Functions to use with html and css to create simple and powerful UI elements
reactive-fns
This library is based on the brilliant [Callbag](https://github.com/callbag/callbag) spec by André Staltz, which allows creating both pullable and listenable streams from simple functions. That makes it lightweight and flexible and that's why it shines wh
npm install simple-fns
Typescript
Module System
Node Version
NPM Version
72.1
Supply Chain
98.4
Quality
75.5
Maintenance
100
Vulnerability
100
License
added explanation to using 'd' delete flag in merge objects
Updated on Jan 08, 2023
functionality to flat combine objects and duplicate objects
Updated on Jan 08, 2023
Adjust types to add documentation
Updated on Jan 07, 2023
Edit index.d.ts to fix importing of a single function
Updated on Jan 07, 2023
Add type definitions
Updated on Jan 07, 2023
First release of string functions manupilations
Updated on Jan 06, 2023
JavaScript (100%)
Total Downloads
923
Last Day
2
Last Week
7
Last Month
17
Last Year
171
MIT License
1 Stars
16 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Mar 08, 2023
Minified
Minified + Gzipped
Latest Version
0.2.1
Package Id
simple-fns@0.2.1
Unpacked Size
22.05 kB
Size
5.40 kB
File Count
5
NPM Version
8.19.3
Node Version
14.17.0
Published on
Jan 08, 2023
Cumulative downloads
Total Downloads
Last Day
0%
2
Compared to previous day
Last Week
133.3%
7
Compared to previous week
Last Month
-22.7%
17
Compared to previous month
Last Year
3%
171
Compared to previous year
1
Manupilate strings of all types to get desired output
import the js-fns library
1const { splitText, countOccurance } = require('simple-fns'); 2 3// or 4 5const jsFns = require('simple-fns');
Split a string into an array as well as the count for the length using a specified delimiter
options
1const result = splitText('test test test', ' '); 2 3// result -> { total: 3, list: ['test', 'test', 'test']} 4 5// or 6const result = splitText('test test test', ' ', 0); 7 8// result -> {total: 3,list: ['test', 'test', 'test']}
1const result = splitText('test test test', ' ', 1); 2 3// result -> { total: 3} 4 5// or 6const result = splitText('test , test , test', ',', 1); 7 8// result -> { total: 3}
1const result = splitText('test test test', ' ', 2); 2 3// result -> {list: ['test', 'test', 'test']} 4 5// or 6const result = splitText('test , test , test', ',', 2); 7 8//result -> {list: ['test', 'test', 'test']} 9// Note: if the delimeter is other than ' ' (space), then all whitespaces will be trimmed from the string before the array is returned.
Count the number of times a character occurs in a string
options
1const result1 = countOccurance('Home-work-Space-'); 2// result1 -> 2 3 4const result2 = countOccurance('homeworkspace'); 5// result2 -> 0 6 7const result3 = countOccurance('homeworkSpace', 0); 8// result3 -> 1 9 10const result4 = countOccurance('homeworkSpace', 0, ''); 11// result4 -> 1 12 13const result5 = countOccurance('homeworkSpace', 0, ' '); 14// result5 -> 1 15 16const result6 = countOccurance('homeworkSpace', 0, ','); 17// result6 -> 1
1const result1 = countOccurance('Home-work-Space-', 1); 2// result1 -> 11 3 4const result2 = countOccurance('Home work Space', 1); 5// result2 -> 11 6 7const result3 = countOccurance('Home work Space ', 1); 8// result3 -> 11 9 10const result4 = countOccurance('Home, work , Space ', 1); 11// result4 -> 11 12 13const result5 = countOccurance('homeworkspace', 1, ','); 14// result5 -> 13
1const result1 = countOccurance('1ome-2ork-3pace-', 2); 2// result1 -> 3 3 4const result2 = countOccurance('1234', 2); 5// result2 -> 4 6 7const result3 = countOccurance('-1', 2); 8// result3 -> 1 9 10const result4 = countOccurance('1,2,3,4,5', 2); 11// result4 -> 5 12 13const result5 = countOccurance('4 6 . 7', 2); 14// result5 -> 3
1const result1 = countOccurance('1ome-2ork-3pace-', 3, ' '); 2// result1 -> 0 3 4const result2 = countOccurance('1 2 3 4', 3); 5// result2 -> 3 6 7const result3 = countOccurance(' 1 2 3 4 ', 3); 8// result3 -> 5 9 10const result4 = countOccurance(' 0 ', 3); 11// result4 -> 2 12 13const result5 = countOccurance('Home Work Space ', 3, ' '); 14// result5 -> 4
1const result1 = countOccurance('1ome-2ork-3pace-', 4, '-'); 2// result1 -> 3 3 4const result2 = countOccurance('1ome-2ork-3pace-', 4, '- '); 5// result2 -> 3 6 7const result3 = countOccurance('1ome-2ork-3pace-', 4, ' - '); 8// result3 -> 3 9 10const result4 = countOccurance('1ome/2ork/3pace/', 4, '/'); 11// result4 -> 3 12 13const result5 = countOccurance('boy , girl , kid , child', 4, ','); 14// result5 -> 3 15 16const result5 = countOccurance('boy , girl , kid , child', 4, '/'); 17// result5 -> 0
Combine two objects in different arrays using their shared identifier
1"with 'd' specified, you indicate that you want 'my_id' as a key to be deleted from the returned array objects"; 2 3const result1 = mergeObjects( 4 [{ id: 1, name: 'Isaac', age: 20 }], 5 [{ my_id: 1, address: 'Kampala' }], 6 'id', 7 'my_id', 8 'd' 9); 10 11// output -> [{id: 1, name: 'Isaac', age: 20, address: 'Kampala'}] 12 13const result2 = mergeObjects( 14 [{ id: 1, name: 'Isaac', age: 20 }], 15 [{ my_id: 1, address: 'Kampala' }], 16 'id', 17 'my_id' 18); 19 20// output -> [{id: 1, name: 'Isaac', age: 20, my_id: 1, address: 'Kampala'}] 21 22const result3 = mergeObjects( 23 [{ id: 1, name: 'Isaac', age: 20 }], 24 [{ id: 1, address: 'Kampala' }], 25 'id', 26 'id' 27); 28// output -> [{id: 1, name: 'Isaac', age: 20, address: 'Kampala'}] 29 30const result4 = mergeObjects( 31 [{ id: 1, name: 'Isaac', age: 20 }], 32 [{ id: 1, address: 'Kampala' }], 33 'id', 34 'id', 35 'd' 36); 37// output -> [{'Isaac', age: 20, address: 'Kampala'}]
Inject objects from one array with duplicate id into the main array
1const result1 = injectDupObj( 2 [ 3 { id: 1, name: 'john1', age: 30 }, 4 { id: 2, name: 'john2', age: 30 }, 5 { id: 3, name: 'john3', age: 30 }, 6 { id: 4, name: 'john4', age: 30 }, 7 { id: 5, name: 'john5', age: 30 }, 8 ], 9 [ 10 { id: 1, user_id: 1, course: 'SST' }, 11 { id: 2, user_id: 2, course: 'English' }, 12 { id: 3, user_id: 1, course: 'Science' }, 13 { id: 8, user_id: 1, course: 'Christianity' }, 14 { id: 4, user_id: 2, course: 'Luganda' }, 15 { id: 5, user_id: 3, course: 'Runyankole' }, 16 { id: 6, user_id: 4, course: 'Swahili' }, 17 { id: 7, user_id: 7, course: 'Luo' }, 18 ], 19 'id', 20 'user_id', 21 'courses' 22); 23// lookupKey is optional, if not give, the inner array will have 'lookup' as its key 24// output 25[ 26 { 27 id: 1, 28 name: 'john1', 29 age: 30, 30 courses: [ 31 { id: 1, user_id: 1, course: 'SST' }, 32 { id: 3, user_id: 1, course: 'Science' }, 33 { id: 8, user_id: 1, course: 'Christianity' }, 34 ], 35 }, 36 { 37 id: 2, 38 name: 'john2', 39 age: 30, 40 courses: [ 41 { id: 2, user_id: 2, course: 'English' }, 42 { id: 4, user_id: 2, course: 'Luganda' }, 43 ], 44 }, 45 { 46 id: 3, 47 name: 'john3', 48 age: 30, 49 courses: [{ id: 5, user_id: 3, course: 'Runyankole' }], 50 }, 51 { 52 id: 4, 53 name: 'john4', 54 age: 30, 55 courses: [{ id: 6, user_id: 4, course: 'Swahili' }], 56 }, 57 { id: 5, name: 'john5', age: 30 }, 58];
0.1.0
, if you experience any issue, runnpm i simple-fns@0.0.1
to install a previous version without typesNo vulnerabilities found.
No security vulnerabilities found.