Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is missing ? should be implemented next ? #43

Open
nreynis opened this issue Sep 15, 2019 · 0 comments
Open

What is missing ? should be implemented next ? #43

nreynis opened this issue Sep 15, 2019 · 0 comments

Comments

@nreynis
Copy link
Contributor

nreynis commented Sep 15, 2019

I made a matrix comparing JS array API, PHP anc Chain.
I've matched the methods when possible.
I haven't dig into JS objects API, nor lodash or reactivex yet.

  JS PHP Chain comments
✔️ length count count  
copyWithin      
✔️ fill array_fill fill  
  array_fill_keys    
✔️   array_flip flip  
✔️ pop array_pop pop  
✔️ push array_push push  
✔️ reverse array_reverse reverse  
✔️ shift array_shift shift  
✔️ splice array_splice splice  
✔️ unshift array_unshift unshift  
✔️ concat array_merge merge  
✔️   array_merge_recursive merge (with option recursive = true)  
✔️ includes in_array   implemented
✔️ indexOf array_search search  
lastIndexOf      
✔️ join implode join  
✔️ slice array_slice slice  
entries      
✔️ every     implemented
✔️ filter array_filter filter  
✔️ find   find  
findIndex      
forEach array_walk   TODO: implement, what would be a good name? walk, or tap (used in reactivex, also used in lodash but with different semantic) or peek (used in java streams API)
  array_walk_recursive   TODO: implement as an option
✔️ keys array_keys keys  
flat     TODO: implement
✔️ flatMap   flatMap  
✔️ map   map  
  array_map   PHP implementation is… let's just say it's weird. Better not reuse that.
✔️ reduce array_reduce reduce  
reduceRight     TODO: implement, as an option of reduce maybe ?
✔️ some     implemented
  range   TODO: implement
✔️ values array_values values  
✔️   array_combine combine  
✔️   array_key_exists keyExists  
✔️   array_pad pad  
✔️   array_product product  
✔️   array_rand rand  
✔️   array_sum sum  
✔️   shuffle shuffle  
✔️   array_unique unique  
✔️   reset first  
✔️   end last  
  array_key_first   TODO: implement for orthogonality, we already have the methods for the values
  array_key_last   TODO: implement for orthogonality, we already have the methods for the values
✔️   array_replace replace  
  array_replace_recursive   should replace have a recursive option, like merge ?
✔️   array_change_key_case changeKeyCase  
  array_chunk   TODO: implement
  array_column   TODO: implement, I think pluck (used in underscore, lodash, data tables, …) would be a better name
✔️   array_count_values countValues  
✔️   uasort sort (with callable parameter and option assoc = true)  
✔️ sort usort sort (with callable parameter)  
✔️   arsort sort (with option assoc = true and reverse = true)  
✔️   asort sort (with option assoc = true)  
✔️   rsort sort (with option reverse = true)  
✔️ sort sort sort  
✔️   uksort sortKeys (with callable parameter)  
✔️   krsort sortKeys (with option reverse = true)  
✔️   ksort sortKeys  
✔️   array_diff diff  
  array_diff_assoc   shouldn't diff have a bunch of options like sort ?
  array_diff_key   shouldn't diff have a bunch of options like sort ?
  array_diff_uassoc   shouldn't diff have a bunch of options like sort ?
  array_diff_ukey   shouldn't diff have a bunch of options like sort ?
  array_udiff   shouldn't diff have a bunch of options like sort ?
  array_udiff_assoc   shouldn't diff have a bunch of options like sort ?
  array_udiff_uassoc   shouldn't diff have a bunch of options like sort ?
✔️   array_intersect intersect  
⁉️   array_intersect_assoc intersectAssoc shouldn't intersect have a bunch of options like sort ? Should this be deprecated in favor of intersect with option assoc = true for consistency ?
  array_intersect_uassoc   shouldn't intersect have a bunch of options like sort ?
✔️   array_intersect_key intersectKey  
  array_intersect_ukey   shouldn't intersectKey have a bunch of options like sort ?
  array_uintersect   shouldn't that be in one of the existing intersect operators ?
  array_uintersect_assoc   shouldn't that be in one of the existing intersect operators ?
  array_uintersect_uassoc   shouldn't that be in one of the existing intersect operators ?
  natsort    
  natcasesort    
  array_multisort    
  compact   do not really see use case seems like a legacy method, prefer merge, unshift or push

What I think needs to be implemented:

  • includes (in_array)
  • every
  • flat
  • some
  • range
  • chunk
  • pluck
  • firstKey
  • lastKey
  • walk / tap / peek, not sure about the name

I also noticed that diff and intersect needs some work, some modes aren't supported. Also it would be nice to keep consistency with what has been done in sort.

What's your opinion about that ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant