GithubHelp home page GithubHelp logo

smartprocure / futil-js Goto Github PK

View Code? Open in Web Editor NEW
975.0 975.0 68.0 23.34 MB

F(unctional) util(ities). Resistance is futile.

Home Page: https://smartprocure.github.io/futil-js/

License: MIT License

JavaScript 100.00%

futil-js's People

Contributors

agamemnus avatar chris110408 avatar chrislatorres avatar daedalus28 avatar decrapifier avatar doug-patterson avatar dshishkov avatar frozegnome avatar geosp avatar github-actions[bot] avatar giulianok avatar greenkeeper[bot] avatar hugomarisco avatar jeremyhart-ubt avatar jmdesiderio avatar jonycodes avatar kmachado avatar lsm avatar michsa avatar nico-olivares avatar positivevibes4all avatar rudolph9 avatar s10mcow avatar sadasant avatar sean-clayton avatar sharmaadityahq avatar stellarhoof avatar tvsudhir3 avatar vstlouis avatar

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

futil-js's Issues

Make a fancy logo

Every real library has a fancy logo. We clearly need one.

Maybe something looks like a borg cube?

Housekeeping Issues

  • Add a link to the changelog in the readme
  • Set up CI to auto publish to npm
  • Set up CI to auto run unit tests
  • Document all available methods

Add unwind

Hi! Just as a reminder :) I don't want to forget that.

An in-range update of eslint-plugin-import is breaking the build 🚨

Version 2.4.0 of eslint-plugin-import just got published.

Branch Build failing 🚨
Dependency eslint-plugin-import
Current Version 2.3.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As eslint-plugin-import is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • ❌ ci/circleci Your tests failed on CircleCI Details

Commits

The new version differs by 10 commits.

  • 44ca158 update utils changelog
  • a3728d7 bump eslint-module-utils to v2.1.0
  • 3e29169 bump v2.4.0
  • ea9c92c Merge pull request #737 from kevin940726/master
  • 8f9b403 fix typos, enforce type of array of strings in allow option
  • 95315e0 update CHANGELOG.md
  • 28e1623 eslint-module-utils: filePath in parserOptions (#840)
  • 2f690b4 update CI to build on Node 6+7 (#846)
  • 7d41745 write doc, add two more tests
  • dedfb11 add allow glob for rule no-unassigned-import, fix #671

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Add a domLens for a mutex checkbox/radio scenario

The goal is to capture this use case for radio buttons and mutex checkboxes:

{...{
  onChange: e => { field.value = e.target.value },
  value: option,
  checked: field.value == option,
}}

Given that we have checkboxValues, we probably shouldn't call it checkboxValue as that'd be too close. Likely name would be radioValue which is probably more intuitive than mutexValue

Implement an async flow

I think it can be like this:

export let asyncFlow = (head, ...tail) => async (...params) => asyncFlow(...tail)(await head(...params))

Aspects unit tests are failing.

The should support .onError and before (concurrency, errors, and status aspects) and should support single error unit tests are failing.

Add `recurry`

Add an uncurry fn

Example
(n, f) => _.curry(R.uncurryN(n, f))

Typescript Typings

I am trying to use this library in a Typescript project (expecially the function helpers are great in my case). However, the project itself includes no .d.ts file and there is also none via npm install @types/futil-js.

Would it be possible for the author to create/add a typescript definitions file?

F.postings hangs up if your regex doesn't have the g flag

F.postings(/a/g, 'vuhfaof') returns [ [ 4, 5 ] ]
F.postings(/a/, 'vuhfaof') never returns at all -- you're stuck in the while loop at https://github.com/smartprocure/futil-js/blob/master/src/regex.js#L42-L45 because without the g flag regex.exec() doesn't consume the initial match and so just finds it again forever.

Two possible fixes:

  • add the g flag before the while loop when needed with regex = new RegExp(regex.source, regex.flags + 'g')
    • downside: doesn't really give the behavior that would be expected by a person who on purpose didn't use the g flag. They're expecting the first match.
  • check for the g flag. if it's not present, just return the rest of .exec-ing, else do the while loop
    • or equivalently have the while loop look at a boolean that you flip when you enter it.

Either fix is simple but I'll wait on feedback as to the preferred behavior.

Fix the browser tests

Browser tests are still failing. See: https://circleci.com/gh/smartprocure/futil-js/968?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link

Here's a plain text copy of the issue:

Chrome 26.0.1410 (Windows 7 0.0.0) ERROR
  {
    "message": "Uncaught ReferenceError: __VERSION__ is not defined\nat webpack:///node_modules/lodash/lodash.min.js:5:1 <- src/index.js:5",
    "str": "Uncaught ReferenceError: __VERSION__ is not defined\nat webpack:///node_modules/lodash/lodash.min.js:5:1 <- src/index.js:5"
  }
Chrome 26.0.1410 (Windows 7 0.0.0) ERROR
  {
    "message": "Uncaught ReferenceError: __VERSION__ is not defined\nat webpack:///node_modules/lodash/lodash.min.js:5:1 <- src/index.js:5",
    "str": "Uncaught ReferenceError: __VERSION__ is not defined\nat webpack:///node_modules/lodash/lodash.min.js:5:1 <- src/index.js:5"
  }
Chrome 26.0.1410 (Windows 7 0.0.0): Executed 0 of 0 ERROR (1.06 secs / 0 secs)

Real Docs Website

We should have a real docs site like lodash, ramda, etc.

Currently, we're waiting on lodash 5 progress since we'd like to do the same thing as lodash, but their doc generation is currently unclear while they're working on v5.

%cUnhandled rejection Error: error


Mobile Safari 11.0.0 (iOS 11.0.0) WARN: '%cUnhandled rejection Error: error
    _callee7$@http://localhost:9876/base/test/aspect.spec.js?44eec46c90e131c2bf886429dff1430f699d0a43:14463:34
    tryCatch@http://localhost:9876/base/node_modules/babel-polyfill/dist/polyfill.js?03b9323c0501aae92009b27cf63cea3f4754b408:6151:44
    invoke@http://localhost:9876/base/node_modules/babel-polyfill/dist/polyfill.js?03b9323c0501aae92009b27cf63cea3f4754b408:6442:30
    step@http://localhost:9876/base/test/aspect.spec.js?44eec46c90e131c2bf886429dff1430f699d0a43:14273:202
    promiseReactionJob@[native code]', 'color: red'

`Unhandled promise rejection`

This seems to be reproduced in many browsers:

Mobile Safari 8.0.0 (iOS 8.4.0) ERROR: 'Unhandled promise rejection', AssertionError{message: 'expected promise to be rejected with 'Error: hi from aspect' but it was rejected with 'Error: hi from aspect'', showDiff: true, actual: 'Error: hi from aspect', expected: 'Error: hi from aspect', stack: 'AssertionError@http://localhost:9876/base/test/aspect.spec.js?45512c279a5a25377ccf6505f37f502ef315c0bc:2681:22

Two versions of cascade

The defaultValue for cascade seems like a bit of a hack. Instead, there should probably be two versions, one without the default value named cascade and one with the default value named cascadeOr. The latter would follow the argument order of getOr, that is, default value first.

maybeCall fails passing arguments when calling fn

arrow functions does not binding its own arguments,

  • need to change the signature of maybeCall(fn) to maybeCall(fn, ...args) in order to call fn(...args) inside.

  • add test for passing arguments to fn() call inside maybeCall

Deprecate `In` methods

Using _ as a placeholder obviates the need for the In method conversions, because they only save a single character at the cost of new things to learn:

F.someMethodIn(x) vs
_.someMethod(_, x)

Additionally, sometimes our conversion methods would be useful together, e.g. an In and an On. A good example is unset - you might want to unset both in and on an object, and defining compound conversion conventions seems messy (unsetIon?).

In order to make this work, we either need to explicitly curry all our conversions, or wait for lodash/lodash#3440 to be fixed

Add automated browser testing

This is a followup to #144 to make sure that kind of thing never happens again.

As part of CI, we should run all of our unit tests in every browser. Sauce Labs and Browserstack free for open source so there's very little friction for us to do this.

Add `walkAsync`

This a method to walk a tree with async visitor/iteratee methods

Fix CI

It seems like our master build is failing CI. Locally, it seems like it's due to something with eslint-plugin-mocha from eslint-config-smartprocure πŸ€”

@sadasant any ideas?

Should we run the tests using our src/* files instead of the output lib/* file?

I know that we've been running tests against the lib file to make sure that the build works, but since this is the responsibility of babel, we could focus the tests on our source code instead. Among the benefits, we could perceive: an overall simplification of the npm scripts, cleaner test coverage and faster tests.

Add our tabSort

We use this sort in several places, let's add it here:

let sortByKey = _.curry((key, tabs) => _.sortBy(obj => {
  let ord = _.get(key, obj)
  return ord >= 0 ? ord : ord < 0 ? (tabs.length * 2) + ord
    : tabs.length
}, tabs)

Release on npm as `futil`

Thanks to the awesome @joaonuno, we now have the futil package name!

This ticket is to track all the steps we need to take to make it happen

  • Rename this repo to smartprocure/futil
  • Publish a new version of futil-js with the new repo name and a big deprecation warning at the top of the readme (and ideally with our fancy new logo to keep brand identity consistent)
  • Change package name and release a new version (major or feature? @sean-c is our resident semantic-versioning expert)
  • Run npm deprecate on the futil-js version
  • Update all dependent libraries/projects
  • Enjoy the awesomeness of our new package name

An in-range update of webpack is breaking the build 🚨

Version 3.5.0 of webpack just got published.

Branch Build failing 🚨
Dependency webpack
Current Version 3.4.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As webpack is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details
  • ❌ ci/circleci Your tests failed on CircleCI Details

Release Notes v3.5.0

Features:

  • add stats.excludeAssets to allow to filter assets in list (@ldrick)
  • add import(/* webpackMode: "weak" */ "module") to try to load a module without network request (@faceyspacey)
  • add 4. argument to require.context which is the context mode. Can be false, "eager", "lazy-once", "weak" and "async-weak". (@faceyspacey)
  • require.resolveWeak now support expressions (@faceyspacey)
  • generate only a single require for modules references in scope-hoisted modules (ModuleConcatenationPlugin)

Bugfixes:

  • keep correct import order when using the ModuleConcatenationPlugin
  • Generate shorter, more readable identifiers in ConcatenatedModule
  • --help output is flushed before process exit (@esbenp)
  • exit code is reliable reported for CLI validation error (@polomsky)
  • stats options are now validated by schema (@esbenp)
  • fixes problem when using the CommonsChunkPlugin in async mode without name argument
  • fixes description of --resolve-extensions (@tomek-d)
  • fixes has no internal name when using dependency variable in root of scope-hoisted modules (ModuleConcatenationPlugin)

Examples:

Commits

The new version differs by 68 commits.

  • 75a8ffe 3.5.0
  • afa28c0 Merge pull request #5453 from webpack/bugfix/import-order-scope-hoisting
  • a569764 Merge pull request #5457 from tomek-d/resolve-extensions-typo
  • 0b8023a fixes #5096
  • 29d1336 Fixed bug in --resolve-extensions parameter documentation
  • 39051df update example
  • 7619c43 generate more pretty names for nested concatenation
  • 6607cfa remove ordering in ModuleConcatenationPlugin
  • 2bbbf50 Merge pull request #5437 from esbenp/fix-help-output-test-5345
  • 9f5bffa beautify
  • 334c1c4 remove unused variable
  • 8835751 fix conflict handling
  • 7099fcc update stats test case
  • b77a52b add reserved words to avoid syntax errors
  • 16a5831 use old new Buffer api for node 4

There are 68 commits in total.

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Trampoline recursuve functions with trampoline

A trampoline is a loop that iteratively invokes thunk-returning functions (continuation-passing style). A single trampoline is sufficient to express all control transfers of a program; a program so expressed is trampolined, or in trampolined style; converting a program to trampolined style is trampolining. Trampolined functions can be used to implement tail-recursive function calls in stack-oriented programming languages.–Wikipedia

See this post: http://raganwald.com/2013/03/28/trampolines-in-javascript.html

My dear friend @stefanmaric wrote a trampoline in this Gist: https://gist.github.com/stefanmaric/1dfc01dd3985d5b423f22fcad7c58da2

const trampoline = (fn) => (...args) => {
  let result = fn(...args)
  while (result instanceof Function) result = result()
  return result
}

add _.iteratee support to findApply

The idea is to enable shorthand so a scenario like this:

F.findApply(x => x.b, [{ c: 1 }, { b: 3 }]) // 3

Could be shortened to this:

F.findApply('b', [{ c: 1 }, { b: 3 }]) // 3

Just requires wrapping f in _.iteratee in collection.js

Misc improvements to documentation

It'd be useful for quickly browsing the documentation if:

  1. Functions were sorted alphabetically
  2. There was a search box to quickly zero-in on a given function.
  3. Documentation could be exported to different formats for offline viewing (PDF, Markup, etc...)

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.