waldojeffers / conductor Goto Github PK
View Code? Open in Web Editor NEWMix both synchronous and asynchronous code without hassle
Home Page: https://conductor.js.org
License: MIT License
Mix both synchronous and asynchronous code without hassle
Home Page: https://conductor.js.org
License: MIT License
To do
map
should accept an input string: map('key')
map
should accept an input path string to allow several level-deep plucking: map('data.errors.0')
pluck
They should accept Functions or Booleans
or(true, false)() // true
or(n => n % 2 === 0, n => n % 1 === 0)(3) // true
or(false, n => n % 2 === 0)(3) // false
Dear WaldoJeffers,
May you develop a diff
method, please?
Cheers.
Checklist
Arrays, Sets, Objects, Maps
equals
source, and replace Array.prototype.every
where necessaryChecklist
Add a chunk method, like Lodash's
Checklist
Hello @WaldoJeffers ,
I think you make a mistake in your doc for "compose" section.
is not rather minus3 = 3-x ?
import {compose} from '@waldojeffers/conductor'
const times2 = x => 2 * x
const minus3 = x => 3 * x
const times2Async = async x => times2(x) // async keyword makes it return a Promise
const minus3Async = async x => minus3(x) // async keyword makes it return a Promise
compose(minus3, times2)(5) // 7
await compose(minus3Async, times2Async)(2, 5) // 7 : we need to await because it is an async function
await compose(minus3, times2Async) // 7
await compose(minus3Async, times2) // 7
Checklist
Currently, awaitAll
is only used internally by map
.
Or has
? has
vs hasProp
?
Currently there's no way to flatten a nested list such as [1, 2, [3, 4, [5, 6], [7, 8]]]
into [1, 2, 3, 4, 5, 6 , 7, 8]
.
Checklist
Currently, as curry
checks the number of passed parameters against the function's length
property, curried functions can not have optional parameters, which can be frustrating at times.
Ideas
curryN
to define the minimum number of required parameters to make the function work. Execute the function as soon as that number has been reachedtoString()
representation of the function to see how many optional parameters there areWarning
const add = (a, b, c = 3)
curry(add)(1, 2) // should be 6
curry(add)(1, 2, 4) // should be 7
Make sure the code coverage remains the same while adding new code
Checklist
Description
Document all methods on GitBook
Checklist
// Something like
const newMessage = { id : 3, message : 'Here' };
const updatedMessage = { id : 1, message : 'Bye' };
const messages = [{ id : 1, message : 'HEY' }, { id : 2, message: 'HI' }]
// Insert
expect(upsert(messages, item => item.id === newMessage.id, newMessage))
.toEqual([{ id : 1, message : 'HEY' }, { id : 2, message: 'HI' }, { id : 3, message : 'Here' }]);
// Update
expect(upsert(messages, item => item.id === updatedMessage.id, updatedMessage))
.toEqual([{ id : 1, message : 'Bye' }, { id : 2, message: 'HI' }, { id : 3, message : 'Here' }]);
Checklist
equals
for quality checkupsert
To do:
equal
, not ===
Title says it all 👍 Beware of import paths in the __tests__
folder
My use case is the following :
// I have two arrays representing two differents entities
// linked with a foreign key: userId
const arrays = [
[{ userId: 1, item: 'junk' }, { userId: 2, item: 'junk2' }],
[{ userId: 1, stuff: 'stuff' }, { userId: 2, stuff: 'stuff2' }]
];
// I want to merge these two arrays and their entities by this foreign key
const result = [
{ userId: 1, item: 'junk', stuff: 'stuff' } ,
{ userId: 2, item: 'junk2', stuff: 'stuff2' }
]
It can be implemented using compose
, reduce
& values
but it's cumbersome :
compose(
values,
reduce(
(acc, item) =>
reduce(
(innerAcc, innerItem) => ({
...innerAcc,
[innerItem.uid]: {
...(innerAcc[innerItem.uid] || {}),
...innerItem,
},
}),
acc,
item,
),
{},
)
)
An similar issue was opened in ramda. I think it's a common use case.
Checklist
replace
should accept the value or the key it's trying to replaceAdd a take method, equivalent to len => slice(0, len)
mapSeries
vs map
)compose(a, b, c) /* c -> b -> a, series */
forEach([a, b, c]) /* a // b // c, parallel */
map([a, b, c]) /* a // b // c, parallel */
reduce([a, b, c]) /* a -> b -> c, series */
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.