New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nodash

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodash - npm Package Compare versions

Comparing version 0.6.3 to 0.7.0

benchmark/index.js

13

CHANGELOG.md

@@ -46,6 +46,15 @@ Changelog

v0.6.1
------
### v0.6.1
+ Changed name from `node-prelude` to `nodash`
v0.7 "Eich"
-----------
+ `isInfinite` exported as utility function
+ `keys` for enumerating the keys of an object
+ `cycle` /w array, string, object, streams, and inifinite streams
+ Reproduces the complete Haskell 2010 Prelude
+ All occurences of `Prelude` are now `Nodash`

8

gulpfile.js

@@ -28,3 +28,3 @@ /* vim: set et sw=2 ts=2: */

gulp.task('minify', [ 'lint' ], function (done) {
gulp.src('prelude.js')
gulp.src('nodash.js')
.pipe(uglify({ }))

@@ -38,3 +38,3 @@ .pipe(rename({ suffix: '.min' }))

gulp.task('gzip', [ 'minify' ], function (done) {
gulp.src('prelude.min.js')
gulp.src('nodash.min.js')
.pipe(gzip({ append: true, gzipOptions: { level: 9 } }))

@@ -46,3 +46,3 @@ .pipe(gulp.dest('.'))

gulp.task('lint', function (done) {
gulp.src([ 'prelude.js', 'test/*.js' ])
gulp.src([ 'nodash.js', 'test/*.js' ])
.pipe(jshint())

@@ -56,3 +56,3 @@ .pipe(jshint.reporter('default'))

gulp.task('coverage', [ 'lint' ], function (done) {
gulp.src('prelude.js')
gulp.src('nodash.js')
.pipe(istanbul())

@@ -59,0 +59,0 @@ .pipe(istanbul.hookRequire())

{
"name": "nodash",
"version": "0.6.3",
"version": "0.7.0",
"description": "A port of the Haskell Prelude to JavaScript/NodeJS",
"main": "prelude.js",
"main": "nodash.js",
"scripts": {

@@ -7,0 +7,0 @@ "test": "gulp test"

@@ -6,2 +6,23 @@ nodash

***nodash*** offers you a rich set of library functions, comparable to
the likes of [***underscore***](http://underscorejs.org/)
or [***lodash***](https://lodash.com/).
The functions are actually derived
from the [***Haskell Prelude***](https://hackage.haskell.org/package/base-4.7.0.0/docs/Prelude.html)
and emphasize a functional programming style.
A special
trait of this library is that it discards some JavaScript concepts (like
`this`) to allow some (in the authors opinion) more useful ones. Every function
from this library can be thought of as *curried*, i.e. you can partially apply
any function and get a function in return (on the other hand this means there are
no optional arguments). Also you have a distinction between *lists* and *streams*
and it can cope with *infinite streams*.
Browse through the [tests](https://github.com/scravy/nodash/tree/master/test) for examples.
Usage
-----
A port of the Haskell Prelude to JavaScript/NodeJS.

@@ -11,7 +32,10 @@

Usage:
```JavaScript
// install it globally
require('nodash').install(GLOBAL);
```JavaScript
var reverse = foldl(flip(cons), []);
// have it in a variable P
var P = require('node-prelude');
var P = require('nodash');

@@ -21,15 +45,7 @@ var reverse = P.foldl(P.flip(P.cons), []);

// have it in a variable Prelude
var Prelude = require('node-prelude');
var Prelude = require('nodash');
var reverse = Prelude.foldl(Prelude.flip(Prelude.cons), []);
// install it globally
require('node-prelude').install(GLOBAL);
var reverse = foldl(flip(cons), []);
// combined
var P = require('node-prelude').install(GLOBAL);
var reverse = foldl(flip(P[':']), []);
// I think you get my drift.
```

@@ -36,0 +52,0 @@

@@ -1,2 +0,2 @@

require('../prelude').install(GLOBAL);
require('../nodash').install(GLOBAL);
var assert = map(flip, require('assert'));

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

var P = require('../prelude').install(GLOBAL);
var P = require('../nodash').install(GLOBAL);
var assert = map(flip, require('assert'));

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

var P = require('../prelude').install(GLOBAL);
var P = require('../nodash').install(GLOBAL);
var assert = map(flip, require('assert'));

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

require('../prelude').install(GLOBAL);
require('../nodash').install(GLOBAL);
var assert = map(flip, require('assert'));

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

require('../prelude').install(GLOBAL);
require('../nodash').install(GLOBAL);
var assert = require('assert');

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

require('../prelude').install(GLOBAL);
require('../nodash').install(GLOBAL);
var assert = map(flip, require('assert'));

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

require('../prelude').install(GLOBAL);
require('../nodash').install(GLOBAL);
var assert = map(flip, require('assert'));

@@ -19,4 +19,4 @@

);
});
});
it('foldl1', function () {

@@ -103,2 +103,9 @@ assert.strictEqual(7*1*4*3, foldl1(times, [7, 1, 4, 3]));

it('scanl /w infinite stream', function () {
assert.deepEqual(
[[], [7], [7, 7]],
consume(take(3, scanl(flip(cons), [], repeat(7))))
);
});
it('scanl1', function () {

@@ -105,0 +112,0 @@ assert.deepEqual([7, 7, 28, 84], scanl1(times, [7, 1, 4, 3]));

@@ -1,2 +0,2 @@

var P = require('../prelude').install(GLOBAL);
var P = require('../nodash').install(GLOBAL);
var assert = map(flip, require('assert'));

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

require('../prelude').install(GLOBAL);
require('../nodash').install(GLOBAL);
var assert = require('assert');

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

var P = require('../prelude').install(GLOBAL);
var P = require('../nodash').install(GLOBAL);
var assert = map(flip, require('assert'));

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

var P = require('../prelude').install(GLOBAL);
var P = require('../nodash').install(GLOBAL);
var assert = map(flip, require('assert'));

@@ -113,2 +113,9 @@

it('append /w infinite stream', function () {
assert.deepEqual(
[ 9, 9, 9, 9, 9 ],
consume(take(5, append(repeat(9), stream([ 8, 7 ]))))
);
});
it('take', function () {

@@ -115,0 +122,0 @@ assert.deepEqual([], take(0, [ 10, 4, 18, 17 ]));

@@ -1,2 +0,2 @@

require('../prelude').install(GLOBAL);
require('../nodash').install(GLOBAL);
var assert = map(flip, require('assert'));

@@ -50,2 +50,7 @@

it("listToMaybe /w stream", function () {
assert.strictEqual(9, listToMaybe(repeat(9)));
assert.strictEqual(null, listToMaybe(take(0, repeat(9))));
});
it("maybeToList", function () {

@@ -52,0 +57,0 @@ assert.deepEqual([ 9 ], maybeToList(9));

@@ -1,2 +0,2 @@

var P = require('../prelude');
var P = require('../nodash');
var assert = require('assert');

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

require('../prelude').install(GLOBAL);
require('../nodash').install(GLOBAL);
var assert = require('assert');

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

var P = require('../prelude');
var P = require('../nodash');
var assert = require('assert');

@@ -3,0 +3,0 @@

@@ -26,3 +26,3 @@ var DumbMath = {

before(function () {
P = require('../prelude').install(undefined, DumbMath, {}, {}, true);
P = require('../nodash').install(undefined, DumbMath, {}, {}, true);
});

@@ -35,5 +35,9 @@

it('isArray in map', function () {
it('isArray in map /w object', function () {
var plus1 = P.map(P.plus(1));
assert.deepEqual({ a: 2, b: 3 }, plus1({ a: 1, b: 2 }));
var a = { x: 3 };
var b = Object.create(a);
b.z = 19;
assert.deepEqual({ z: 20 }, plus1(b));
});

@@ -99,1 +103,36 @@

});
describe('Polyfills /w enum bug', function () {
var P;
before(function () {
P = require('../nodash').install(undefined, DumbMath, {}, {}, true, {});
});
it('isArray in map', function () {
var plus1 = P.map(P.plus(1));
assert.deepEqual([2, 3, 4], plus1([1, 2, 3]));
});
it('isArray in map /w object', function () {
var plus1 = P.map(P.plus(1));
assert.deepEqual({ a: 2, b: 3 }, plus1({ a: 1, b: 2 }));
var a = { x: 3 };
var b = Object.create(a);
b.toString = 19;
assert.deepEqual({ toString: 20 }, plus1(b));
});
it('nub', function () {
assert.deepEqual([1,2,4], P.nub([1,1,2,4,4,4]));
});
it('union', function () {
assert.deepEqual([1,2,4], P.union([1,2], [2,4]));
});
it('intersect', function () {
assert.deepEqual([3,2], P.intersect([1,3,2], [5,2,3,4]));
});
});

@@ -1,2 +0,2 @@

require('../prelude').install(GLOBAL);
require('../nodash').install(GLOBAL);
var assert = require('assert');

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

require('../prelude').install(GLOBAL);
require('../nodash').install(GLOBAL);
var assert = map(flip, require('assert'));

@@ -67,2 +67,36 @@

});
it('cycle /w array', function () {
var s = cycle([ 1, 2, 3 ]);
assert.strictEqual(true, isInfinite(s));
assert.deepEqual([ 1, 2, 3, 1, 2, 3, 1, 2, 3 ], consume(take(9, s)));
});
it('cycle /w string', function () {
var s = cycle("abc");
assert.strictEqual(true, isInfinite(s));
assert.deepEqual("abcabcabc", consumeString(take(9, s)));
});
it('cycle /w stream', function () {
var s = cycle(lazy("abc"));
assert.strictEqual(true, isInfinite(s));
assert.deepEqual("abcabcabcabc", consumeString(take(12, s)));
});
it('cycle /w infinite stream', function () {
var random = cycle(stream(function () {
return 4;
}));
assert.strictEqual(true, isInfinite(random));
assert.deepEqual([ 4, 4, 4, 4 ], consume(take(4, random)));
});
it('cycle /w object', function () {
var xs = cycle({ a: 1, b: 2, c: 3 });
assert.strictEqual(true, isInfinite(xs));
var result = consume(take(6, xs));
assert.deepEqual([], difference(result, [ 1, 2, 3 ]));
assert.deepEqual([ 3, 2, 1 ], union([ 3, 2, 1 ], result));
});
});

@@ -1,2 +0,2 @@

require('../prelude').install(GLOBAL);
require('../nodash').install(GLOBAL);
var assert = map(flip, require('assert'));

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

var P = require('../prelude').install(GLOBAL);
var P = require('../nodash').install(GLOBAL);
var assert = require('assert');

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

require('../prelude').install(GLOBAL);
require('../nodash').install(GLOBAL);
var assert = require('assert');

@@ -3,0 +3,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc