Giter Site home page Giter Site logo

ramdasauce's Introduction

NOTE: this library is no longer maintained.

Ramdasauce

Adds a few utilities based on the delicious Ramda library.

npm module

Installing

npm i ramdasauce --save

  • Depends on ramda 0.24.+.
  • Targets ES5.
  • Built with ES6.

Usage

Here's the quick list of functions and a simple example.

import RS from 'ramdasauce'

// --- Conversions ---
RS.toDate(1e12)             // a Number to a date Object
RS.toNumber('5')            // a String to a Number

// --- Object Shenanigans ---
const x = {a: 1, b: 2, c: {x: [5, 6]}}
RS.mapKeys(R.toUpper, x)    // transforms the keys of an object by the function
RS.dotPath('c.x.0', x)      // fetches a value from a nested object by a string path

// --- Generating Things ---
RS.rangeStep(2, 2, 10)      // generates a range of numbers with a step

// --- Finding Things ---
RS.findByProp('id', 'a', [{id: 'a', id: 'b'}])      // finds an object by propEq
RS.findIndexByProp('id', 'a', [{id: 'a', id: 'b'}]) // finds the index of an object by propEq

// --- Predicates ---
RS.isUndefined(qwerty)      // check if something is undefined
RS.isNotNil(null)           // check if something is not null or undefined
RS.isNilOrEmpty(null)       // checks if something is null, undefined or R.isEmpty
RS.isWithin(1, 2, 2)        // is the 3rd parameter within the range of 1st through 2nd?
RS.isNotWithin(1, 2, 100)   // is the 3rd parameter not within the range of 1st through 2nd?
RS.eqLength([1,2,3], 'abc') // tests 2 things to see if their length properties are the same

Prior Art

Most of these functions were lifted from stuff I wrote in real projects.

(leans in and whispers)

I did look at these tho:

Philosophy

These helper functions target that sweet spot between:

Not right for ramda core.

and

Would never be used outside your app.

Functions being added here must be used in an app. Preferable more than once.

I hope this library won't turn into something like this:

RS.portmanteau('functor', 'wrecked')
RS.yearsForAnimalInAsianCalendars('monkey')

Feedback

Do you have any common ramda patterns you use frequently? Drop some issues or PRs in!

Release Notes

2.1.0 - Aug 12, 2017

  • upgrades to [email protected]
  • bumped all dev dependencies
  • marked previous mentioned functions with @deprecated in their comments

2.0.0 - May 29, 2017

  • DEPRECATIONS: startsWith and endsWith are flagged for removal in 3.0.0 (ramda has these now)
  • DEPRECATIONS: random and sample are flagged for removal in 3.0.0 (impure functions)
  • DEPRECATIONS: log and trace are flagged for removal in 3.0.0 (impure debug functions)
  • Upgrades to [email protected]
  • updates build process for much smaller bundle sizes

1.2.0 - February 6, 2017

  • Updates isWithin to play nice with Webpack - @hubciorz (#7)
  • Bumped dependencies - @skellock (#8)

1.1.1 - August 17th, 2016

1.1.0 - June 16th, 2016

1.0.0 - April 3rd, 2016

  • Initial Release

ramdasauce's People

Contributors

carlinisaacson avatar hubciorz avatar jamonholmgren avatar kevinvangelder avatar rmevans9 avatar robinheinze avatar semantic-release-bot avatar skellock 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

Watchers

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

ramdasauce's Issues

Invert findByProp

Would be nice to have a function which rejects everything that matches the prop.

import R from 'ramda'

/**
 * Rejects any object in an array by the given property and value.
 *
 * @since v1.0.1
 * @param {prop} (String) The prop to search by.
 * @param {value} (String) The string to search for.
 * @param {source} (Array) The array to search in.
 * @return {Object} The object that matches the search or null if not found.
 * @example
 * RS.rejectByProp('id', 'a', [{id: 'a'}, {id: 'b'}]) //=> {id: 'b'}
 */
const rejectByProp = R.curry(
  (prop, value, source) => R.reject(R.propEq(prop, value))(source)
)

export default rejectByProp

NPM install of latest release doesn't send files

Only included are the package.json and the readme. dist/ramdasauce.js is not downloaded from npm install of latest version of this repo which was posted earlier today.

This is causing metro bundler to fail when react native loads because it can't find the file.

License?

I don't see any license file. Can one be decided on and added to the repository? Would a PR help?

Here is a quote from the license. It is generally interpreted as a copy of the license in the git repository, and in any downloaded copies of the code like from npm or yarn.

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

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.