Giter Club home page Giter Club logo

conductor's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

conductor's Issues

Remove pluck in favor of map('string')

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')
  • remove pluck

Add AND & OR logical operators

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

Add an every method

Checklist

  • It should work on Arrays, Sets, Objects, Maps
  • Use it in equals source, and replace Array.prototype.every where necessary
  • Document it

Add a README

Checklist

  • Title
  • Short description
  • Purpose (already done but should be moved to a separate document)
  • Get started
  • Examples
  • Link to documentation
  • Gitter?
  • Further reading

mistake in doc in compose section

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

Add tests for all methods

Checklist

  • always
  • apply
  • arity
  • branch
  • capitalize
  • compose
  • curry
  • curryN
  • delay
  • dump
  • entries
  • filter
  • findIndex
  • flip
  • forEach
  • get
  • head
  • identity
  • ifElse
  • into
  • isPromise
  • iterate
  • keys
  • map
  • next
  • pluck
  • prepend
  • random
  • reduce
  • replace
  • slice
  • some
  • then
  • toLowerCase
  • transduce
  • transformers
    • filter
    • map
  • type
  • upsert
  • values

Add a flatten method

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].

Add a split method

Checklist

  • It should split a string using a string pattern or a RegExp if the input's a string
  • Documentation

See how optional parameters and currying could work

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

  • use curryN to define the minimum number of required parameters to make the function work. Execute the function as soon as that number has been reached
  • parse the toString() representation of the function to see how many optional parameters there are

Warning

  • additional parameters should only be the last parameters of a function
  • make sure additional parameters are not removed when using the non-curried version
const add = (a, b, c = 3)
curry(add)(1, 2) // should be 6
curry(add)(1, 2, 4) // should be 7

Create a join method

Checklist

  • It should work on all collection types
  • It should be tested
  • It should be documented

Document all methods

Description
Document all methods on GitBook

Checklist

  • always
  • apply
  • arity
  • branch
  • capitalize
  • compose
  • curry
  • curryN
  • delay
  • dump
  • entries
  • filter
  • findIndex
  • flip
  • forEach
  • get
  • head
  • identity
  • ifElse
  • into
  • isPromise
  • iterate
  • keys
  • map
  • next
  • pluck
  • prepend
  • random
  • reduce
  • replace
  • slice
  • some
  • then
  • toLowerCase
  • transduce
  • transformers
    • filter
    • map
  • type
  • upsert
  • values

Add an upsert method for arrays

// 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' }]);

Create a merge method

Checklist

  • It should work on objects
  • It should merge deeply by default
  • It should use equals for quality check
  • It should work on arrays (warning, this will be super slow because need to check if exist)
    • Use upsert
  • Add tests

Create an union method with a merge by key

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.

Replace should work on Collections, not simply arrays

Checklist

  • Decide if replace should accept the value or the key it's trying to replace
  • It should work on objects
  • It should work on sets
  • It should work on maps
  • It should work on strings
    • If the index is a number, it should replace the matching character
    • If the index is a character, it should replace all matching occurrences of this character
    • If the index is RegExp, it should replace all the matches from the RegExp
  • It should accept a function in place of the index parameter
  • Add tests
  • Update documentation

Provide a way to run operations in parallel or in series

  • Users should have a clear way to control the execution flow
  • Having "duplicate" functions to distinguish parallel vs series is frustrating (eg. mapSeries vs map)
  • There are already several functions which implement this logic, use them or make it easier to use their inner concurrency model?
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 */
  • See how others are doing it
    • RxJS
    • Contra
    • promise-fun
    • async

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.