![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
pico-lambda
Advanced tools
460b
functional library based on native array methods
Pico-lambda was made for the ES2015 Javascript Runtime. It has no dependencies.
After installing via npm install
:
const {
concat,
filter,
map,
reduce,
compose
} = require('pico-lambda')
//concat
const arrayOne = [1, 2, 3];
const addTwo = concat([4, 5])
const result = addTwo(arrayOne)
// We can compose instead of chaining
compose(
reduce((acc, val) => val + acc, 0),
map(x => x * 2),
filter(x => x > 5),
concat([6, 7, 8])
)([1, 2, 3, 4, 5])
((e -> f), ..., (b -> c), (a -> b)) -> a -> f
Evaluates the provided functions, right to left, passing the return value
of each function to the next in line.
The initial function is passed the initial value provided to comopse.
The output of the final function, in this case (e->f)
, is returned.
compose(
map(x => x + 1),
map(x => x + 1),
map(x => x + 1)
)([0]) // => 3
[a] -> ([a], ..., [a]) -> [a]
Concatenates two arrays
concat([4, 5])([1,2,3]) // => [1, 2, 3, 4, 5]
concat([4, 5])([1,2], [3]) // => [1, 2, 3, 4, 5]
(Int, Int, Int) -> [a] -> [a]
Makes a shallow copy of part of an array and overwrites another location in the same with the copy. Size is kept constant.
const arr = [1, 2, 3, 4, 5]
copyWithin(3, 1)(arr) // => [1, 2, 3, 2, 3]
copyWithin(3, 1, 2)(arr) // => [1, 2, 3, 2, 5]
[a] -> [b]
Return an iterator over key, value pairs from the array.
const iterator = entries([1, 2, 3, 4, 5])
iterator.next()) // => { value: [0, 1], done: false }
((a, Int, [a]) -> Boolean) -> [a] -> Boolean
Applies predicate to all elements in array and returns false if any fail. The predicate function must at least take one parameter for each element but may optionally take an index and the entire array as 2nd and 3rd parameters, respectively.
const predicate = x => x < 4
every(predicate)([1, 2, 3]) // => true
every(predicate)([1, 2, 3, 4, 5]) // => false
(a, Int, Int) -> [a] -> [a]
Fills a portion of the given array putting the same new value into each slot.
const arr = [1, 2, 3, 4, 5]
fill(1)(arr) // => [1, 1, 1, 1, 1]
fill(1, 2, 4)(arr) // => [1, 2, 1, 1, 5]
See Array.fill (MDN)
((a, Int, [a]) -> Boolean) -> [a] -> [a]
Returns a new array containing only those elements of the given array that pass the given predicate.
const predicate = x => x < 3
filter(predicate)([1, 2, 3, 4, 5]) // => [1, 2]
(a -> Boolean) -> [a] -> a | undefined
Finds and returns the first element in the given array that matches the given predicate. If no element passes, undefined is returned.
const predicate = x => x === 3
find(predicate)([1, 2, 3]) // => 3
find(predicate)([1, 2]) // => undefined
See Array.find (MDN)
(a -> Boolean) -> [a] -> Int
Returns the index of the first element in the given array that matches the given predicate. If no element passes, -1 is returned.
const arr = [1, 2, 3, 4, 5]
const findIndex = x => x === 3
find(x => x > 3)(arr) // => 3
find(x => x > 80)(arr]) // => -1
a -> [a] -> Boolean
Returns true if the given element is in the given array, otherwise false.
const animals = ['dog', 'cat', 'ferret', 'hamster']
const hasCat = includes('cat')
const hasUnicorn = includes('unicorn')
hasCat(animals) // true
hasUnicorn(animals) // false
(a, Int) -> [a] -> Int
Returns the index of the given element if it is in the given array, otherwise -1. The 2nd parameter can be used to change where it starts looking.
indexOf(3)([1, 2, 3, 4, 5]) // => 2
indexOf(3, 3)([[1, 2, 3, 4, 5, 3]) // => 3
String -> [a] -> String
Converts each element of the array to a string and concatenates them together with the given string as a delimiter.
join('-')([1, 2, 3]) // => '1-2-3'
See Array.join (MDN)
[a] -> [Int]
Return an iterator over keys from the array.
const iterator = keys([1, 2, 3, 4, 5])
iterator.next() // => { value: 0, done: false }
See Array.keys (MDN)
(a, Int) -> [a] -> Int
Works like indexOf but starts at the end and works backwards. The 2nd parameter can be used to tell it where to start working backwards from.
lastIndexOf(1)([1, 2, 3, 1]) // => 3
lastIndexOf(1, -2)([1, 2, 3, 1]) // => 0
(a -> b) -> [a] -> [b]
Applies a function over each element in the given array, returning a new array with each functions results.
map(x => x * 2)([1, 2, 3]) // => 2, 4, 6
See Array.map (MDN)
((a -> b), (b -> c), ..., (e -> f)) -> a -> f
Takes an initial value that is passed to the first function in the parameter list. The return value of each subsequent function is passed to the following function. The return value of the last function is returned from pipe.
const arr = [1, 2, 3, 4, 5]
pipe(
unshift(0),
concat([6, 7, 8])
)(arr) // => [0, 1, 2, 3, 4, 5, 6, 7, 8]
See Array.pipe (MDN)
[a] -> [a]
Returns a new array without the last item
pop([1, 2, 3, 4, 5]) // => [1, 2, 3, 4]
See Array.pop (MDN)
a -> [a] -> [a]
Returns a new array with the new element appended to the end of the original array.
push(5)([1, 2, 3, 4]) // => [1, 2, 3, 4, 5]
See Array.push (MDN)
((a, b) -> a) -> a -> [b] -> a
Applies a function against an accumulator and each value of the array (from left-to-right), then returning the accumulator.
((a, b) -> a) -> a -> [b] -> a
Applies a function against an accumulator and each value of the array (from right-to-left), then returning the accumulator.
[a] -> [a]
Returns a new array with the elements in reverse order.
[a] -> [a]
Returns a new array with the first element removed.
(int, int) -> [a] -> [a]
Takes a slice from a given array and returns it as a new array.
(int, int, [a]) -> [a] -> [a]
Returns a new array with the indicated elements removed. An optional set of new elements can be inserted in their place.
(a -> Boolean) -> [a] -> Boolean
Returns true if any element in the given array matches the given predicate.
See Array.some (MDN)
((a, a) -> int) -> [a] -> [a]
Returns a copy of the original array with the values sorted. If a comparator function is provided it should return -1, 0 or 1 depending on whether the first element is less than, equal to or greater than the second, respectively. If no comparator is given, lexical sorting is used.
See Array.sort (MDN)
(String, Obj) -> [a] -> String
Converts each element of an array into a string based on current locale settings or locale options passed in. The resulting strings are appended together using commas.
[a] -> String
Converts each element of an array into a string and appends them together with a comma.
[a] -> [a]
Returns a new copy of an array with the first element removed.
length
- This is a property, not a method, so it doesn't really belong here.forEach
- This is inherently side-effect-y, it adds nothing that can't be done with filter
, map
and reduce
.If you don't agree with anything above that's great! Just log an issue so we can discuss.
FAQs
native functional js
The npm package pico-lambda receives a total of 4 weekly downloads. As such, pico-lambda popularity was classified as not popular.
We found that pico-lambda demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.