ramda
Advanced tools
Comparing version 0.8.0 to 0.9.0
var R = require('../..'); | ||
var setProp = R.curry (function(prop, value, obj) { | ||
var setProp = R.curry(function(prop, value, obj) { | ||
obj[prop] = value; | ||
@@ -5,0 +5,0 @@ return obj; |
@@ -139,3 +139,3 @@ (function(factory) { | ||
*/ | ||
skip: function(n) { | ||
drop: function(n) { | ||
var skip = function(ctr, lz) { | ||
@@ -223,5 +223,5 @@ return (ctr <= 0) ? lz : skip(ctr - 1, lz.tail()); | ||
* @example | ||
* R.repeat(1) //=> [1, 1, 1, ...] | ||
* R.lazylist.repeat(1) //=> [1, 1, 1, ...] | ||
*/ | ||
R.repeat = function(value) { | ||
R.lazylist.repeat = function(value) { | ||
var fn = R.always(value); | ||
@@ -228,0 +228,0 @@ return lazylist(null, fn, fn); |
The MIT License (MIT) | ||
Copyright (c) 2013 Scott Sauyet and Michael Hurley | ||
Copyright (c) 2013-2014 Scott Sauyet and Michael Hurley | ||
@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
@@ -27,3 +27,3 @@ { | ||
"description": "A practical functional library for JavaScript programmers.", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"homepage": "https://www.github.com/ramda/ramda", | ||
@@ -35,4 +35,5 @@ "license": "MIT", | ||
}, | ||
"main": "ramda.js", | ||
"main": "dist/ramda.js", | ||
"scripts": { | ||
"jshint": "grunt jshint", | ||
"test": "grunt test" | ||
@@ -42,18 +43,30 @@ }, | ||
"devDependencies": { | ||
"acorn": "0.9.x", | ||
"benchmark": "~1.0.0", | ||
"commander": "2.5.x", | ||
"deedpoll": "0.2.x", | ||
"dox": "latest", | ||
"envvar": "1.x.x", | ||
"escodegen": "1.4.x", | ||
"gh-pages": "^0.2.0", | ||
"grunt": "~0.4.5", | ||
"grunt-benchmark": "https://github.com/buzzdecafe/grunt-benchmark/archive/09999a8c3fbfff04a1695846c1ccd0bd8a0ef5ab.tar.gz", | ||
"grunt-browserify": "3.2.1", | ||
"grunt-cli": "~0.1.13", | ||
"grunt-contrib-clean": "^0.6.0", | ||
"grunt-contrib-connect": "^0.8.0", | ||
"grunt-contrib-copy": "^0.7.0", | ||
"grunt-contrib-jshint": "~0.10.0", | ||
"grunt-contrib-less": "^1.0.0", | ||
"grunt-docco": "latest", | ||
"grunt-jscs": "~0.7.0", | ||
"grunt-jsdoc": "^0.6.0", | ||
"grunt-jscs": "1.2.x", | ||
"grunt-jsdoc": "^0.6.1", | ||
"grunt-mocha": "~0.4.11", | ||
"grunt-mocha-test": "~0.11.0", | ||
"grunt-saucelabs": "^8.3.1", | ||
"handlebars": "^2.0.0", | ||
"highlight.js": "^8.4.0", | ||
"js-yaml": "^3.2.5", | ||
"lodash": "latest", | ||
"marked": "^0.3.2", | ||
"orchestrate": "~0.3.4", | ||
@@ -60,0 +73,0 @@ "q": "^1.1.1", |
136
README.md
@@ -1,2 +0,2 @@ | ||
Project Ramda | ||
Ramda | ||
============= | ||
@@ -8,36 +8,65 @@ | ||
[![npm module](https://badge.fury.io/js/ramda.svg)](https://www.npmjs.org/package/ramda) | ||
[![dependencies](https://david-dm.org/ramda/ramda.png)](https://david-dm.org/ramda/ramda) | ||
[![dependencies](https://david-dm.org/ramda/ramda.svg)](https://david-dm.org/ramda/ramda) | ||
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/ramda/ramda?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
Goals | ||
----- | ||
Why Ramda? | ||
---------- | ||
<img src="http://ramda.jcphillipps.com/logo/ramdaFilled_200x235.png" | ||
width="200" height="235" align="left" hspace="12" /> | ||
Using this library should feel as much like using Javascript as | ||
possible. Of course it's functional Javascript, but we're not | ||
introducing lambda expressions in strings, we're not borrowing consed | ||
width="170" height="190" align="right" hspace="12" /> | ||
There are already several excellent libraries with a functional flavor such as _Underscore_ and _Lo-Dash_. While they are meant to be general-purpose toolkits, suitable for working in multiple paradigms, we created Ramda differently. We wanted a library designed specifically for a functional programming style, one that made it easy to create functional pipelines, one that never mutated user data. | ||
What's Different? | ||
----------------- | ||
While Ramda includes all of the favorite list-manipulation functions you expect, e.g. `map`, `filter`, `reduce`, `find`, and so forth, Ramda is also significantly different from libraries like _Underscore_ and _Lo-Dash_. | ||
The primary distinguishing features of Ramda are: | ||
* Ramda emphasizes a purer functional style. Immutability and side-effect free functions | ||
are at the heart of its design philosophy. This can help you get the job done with simple, | ||
elegant code. | ||
* Ramda functions are automatically curried. This allows you to easily build up new functions | ||
from old ones simply by not supplying the final parameters. | ||
* The parameters to Ramda functions are arranged to make it convenient for currying. The data | ||
to be operated on is generally supplied last. | ||
The last two points together make it very easy to build functions as sequences of simpler functions, each of which transforms the data and passes it along to the next. Ramda is designed to support this style of coding. | ||
Also see [Why Ramda?](http://fr.umio.us/why-ramda/), [Why Curry Helps](http://hughfdjackson.com/javascript/why-curry-helps/) and [Hey Underscore, You're Doing It Wrong!](https://www.youtube.com/watch?v=m3svKOdZijA&app=desktop). | ||
Philosophy | ||
---------- | ||
Using Ramda should feel much like just using Javascript. | ||
It is practical, functional Javascript. We're not introducing | ||
lambda expressions in strings, we're not borrowing consed | ||
lists, we're not porting over all of the Clojure functions. | ||
Our basic data structures will be normal Javascript objects, and our | ||
usual collections will be Javascript arrays. We will not try to reach | ||
the point where all the functions have only zero, one, or two arguments. | ||
We will certainly try to keep some of the normal features of Javascript | ||
that seem to be unusual in functional languages, including variable | ||
length function signatures and functions as objects with properties. | ||
Our basic data structures are plain Javascript objects, and our | ||
usual collections are Javascript arrays. We also keep other | ||
native features of Javascript, such as functions as objects | ||
with properties. | ||
Ramda will never be a drop-in replacement for Underscore (or LoDash, or | ||
even a drop-in-and-mechanically-switch-the-parameter-order-everywhere | ||
replacement.) It is intended to work with a different style of coding. | ||
While offering similar functionality, Ramda will never be a drop-in | ||
replacement for _Underscore_ / _Lo-Dash_. Ramda is intended to work with a | ||
different style of coding. | ||
Functional programming is in good part about immutable objects and | ||
side-effect free functions. While Ramda does not expect to do anything to | ||
*enforce* that style, its code should always work to make that style as | ||
frictionless as possible. | ||
side-effect free functions. While Ramda does *not enforce* this, it | ||
enables such style to be as frictionless as possible. | ||
As much as we can, we would like the implementation to be both clean and | ||
elegant. But the API is king: we will sacrifice a great deal of | ||
implementation elegance for even a slightly cleaner API. | ||
We aim for an implementation both clean and elegant, but the API is king. | ||
We sacrifice a great deal of implementation elegance for even a slightly | ||
cleaner API. | ||
Unlike the developers of that silly-named _Eweda_ project, though, this | ||
one will focus also on performance, striving for a reliable and quick | ||
implementation over any notions of functional purity. | ||
Last but not least, Ramda strives for performance. A reliable and quick | ||
implementation wins over any notions of functional purity. | ||
@@ -74,3 +103,3 @@ Installation | ||
```html | ||
<script src="//cdnjs.cloudflare.com/ajax/libs/ramda/0.8.0/ramda.min.js"></script> | ||
<script src="//cdnjs.cloudflare.com/ajax/libs/ramda/0.9.0/ramda.min.js"></script> | ||
``` | ||
@@ -81,4 +110,4 @@ | ||
```html | ||
<script src="//cdn.jsdelivr.net/ramda/0.8.0/ramda.min.js"></script> | ||
<script src="//cdn.jsdelivr.net/ramda/0.8/ramda.min.js"></script> | ||
<script src="//cdn.jsdelivr.net/ramda/0.9.0/ramda.min.js"></script> | ||
<script src="//cdn.jsdelivr.net/ramda/0.9/ramda.min.js"></script> | ||
<script src="//cdn.jsdelivr.net/ramda/latest/ramda.min.js"></script> | ||
@@ -124,41 +153,3 @@ ``` | ||
Structure | ||
--------- | ||
### Automatic Currying ### | ||
The functions included should automatically allow for partial | ||
application without an explicit call to lPartial. Many of these operate | ||
on lists. A single list parameter should probably come last, which | ||
might conflict with the design of other libraries that have strong | ||
functional components (I'm looking at you Underscore!) | ||
The idea is that, if foldl has this signature: | ||
```javascript | ||
var foldl = function(fn, accum, arr) { /* ... */} | ||
``` | ||
and we have this simple function: | ||
```javascript | ||
var add = function(a, b) {return a + b;}; | ||
``` | ||
then, instead of having to manually call lPartial like this: | ||
```javascript | ||
var sum = lPartial(foldl, add, 0); | ||
var total = sum([1, 2, 3, 4]); | ||
``` | ||
with ramda, we can just do this: | ||
```javascript | ||
var sum = foldl(add, 0); | ||
var total = sum([1, 2, 3, 4]); | ||
``` | ||
Running The Test Suite | ||
@@ -196,3 +187,3 @@ ---------------------- | ||
If you have PhantomJS installed, you can run `testem -l phantomjs` to run the | ||
If you have _PhantomJS_ installed, you can run `testem -l phantomjs` to run the | ||
tests completely headlessly. | ||
@@ -204,12 +195,3 @@ | ||
So What's With Eweda? | ||
--------------------- | ||
The [eweda library](https://github.com/CrossEye/eweda) was written by | ||
the developers of this library, with similar goals. But that one strove | ||
more for implementation elegance than for practical capabilities. Ramda | ||
is all about giving users real-world tools. Eweda can be seen more as | ||
an academic excercise, mostly proving out what does and doesn't work, and | ||
doing so as elegantly as possible. | ||
Acknowledgements | ||
@@ -216,0 +198,0 @@ ----------------- |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
472020
269
12558
33
197
1