Comparing version 0.9.0 to 0.9.1
@@ -1,4 +0,5 @@ | ||
`(a -> Bool) -> [a] -> Bool` | ||
`(a → Bool) → [a] → Bool` | ||
Applied to a predicate and a list, all determines if all elements of the list satisfy the predicate. For the result to be True, the list must be finite; False, however, results from a False value for the predicate applied to an element at a finite index of a finite or infinite list. | ||
Applied to a predicate and a list, all determines if all elements of the list | ||
satisfy the predicate. | ||
@@ -10,1 +11,6 @@ Example: | ||
This function does work with strings too: | ||
all(isDigit, "123") === true | ||
@@ -510,3 +510,3 @@ /* vim: set et sw=2 ts=2: */ | ||
register('/=', 'neq', 'NEQ', function _neq(a, b) { | ||
register('/=', '!=', '<>', 'neq', 'NEQ', function _neq(a, b) { | ||
return !Nodash.eq(a, b); | ||
@@ -580,19 +580,40 @@ }); | ||
register('isNumeric', isNumeric); | ||
register('isDigit', 'isNumeric', isNumeric); | ||
register('isDigit', function _isDigit(x) { | ||
return !!x.match(/[0-9]/); | ||
}); | ||
register('isAsciiLetter', function _isAsciiLetter(x) { | ||
return !!x.match(/[a-zA-Z]/); | ||
return !!x.match(/^[a-zA-Z]+$/); | ||
}); | ||
register('isUpper', function _isUpper(x) { | ||
return x === x.toUpperCase(); | ||
register('isLetter', function _isLetter(x) { | ||
var xUpper = x.toUpperCase(); | ||
var xLower = x.toLowerCase(); | ||
for (var i = 0; i < x.length; i += 1) { | ||
if (xUpper[i] === xLower[i]) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}); | ||
register('isLower', function _isLower(x) { | ||
return x === x.toLowerCase(); | ||
register('isUpper', function _isLetter(x) { | ||
var xUpper = x.toUpperCase(); | ||
var xLower = x.toLowerCase(); | ||
for (var i = 0; i < x.length; i += 1) { | ||
if (xUpper[i] === xLower[i] || x[i] !== xUpper[i]) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}); | ||
register('isLower', function _isLetter(x) { | ||
var xUpper = x.toUpperCase(); | ||
var xLower = x.toLowerCase(); | ||
for (var i = 0; i < x.length; i += 1) { | ||
if (xUpper[i] === xLower[i] || x[i] !== xLower[i]) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}); | ||
@@ -599,0 +620,0 @@ register('ord', function _ord(x) { |
{ | ||
"name": "nodash", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"description": "A port of the Haskell Prelude to JavaScript/NodeJS", | ||
@@ -5,0 +5,0 @@ "main": "nodash.js", |
@@ -21,3 +21,6 @@ nodash | ||
Browse through the [tests](https://github.com/scravy/nodash/tree/master/test) for examples. | ||
Browse through the | ||
[apidoc](https://scravy.github.io/nodash/apidoc.html), | ||
[benchmark](https://github.com/scravy/nodash/tree/master/benchmark/index.js), or | ||
[tests](https://github.com/scravy/nodash/tree/master/test) for examples. | ||
@@ -59,5 +62,5 @@ | ||
```JavaScript | ||
var P = require('nodash'); | ||
var Nodash = require('nodash'); | ||
var reverse = P.foldl(P.flip(P.cons), []); | ||
var reverse = Nodash.foldl(Nodash.flip(Nodash.cons), []); | ||
``` | ||
@@ -64,0 +67,0 @@ |
@@ -17,2 +17,3 @@ var P = require('../nodash').install(GLOBAL); | ||
assert.strictEqual(true, isUpper('ABC')); | ||
assert.strictEqual(false, isUpper('HELLO_WORLD')); | ||
assert.strictEqual(false, isUpper('ABdC')); | ||
@@ -24,2 +25,3 @@ assert.strictEqual(false, isUpper('def')); | ||
assert.strictEqual(true, isLower('xyz')); | ||
assert.strictEqual(false, isLower('abc123')); | ||
assert.strictEqual(false, isLower('ABdC')); | ||
@@ -29,3 +31,37 @@ assert.strictEqual(false, isLower('KLM')); | ||
it('isLetter', function () { | ||
assert.strictEqual(true, isLetter('a')); | ||
assert.strictEqual(true, isLetter('abc')); | ||
assert.strictEqual(true, isLetter('A')); | ||
assert.strictEqual(true, isLetter('ABC')); | ||
assert.strictEqual(false, isLetter('a9')); | ||
assert.strictEqual(false, isLetter('ab-c')); | ||
assert.strictEqual(false, isLetter(' ')); | ||
}); | ||
it('isNumeric /w "abc"', function () { | ||
assert.strictEqual(false, isNumeric("abc")); | ||
}); | ||
it('isNumeric /w "abc456"', function () { | ||
assert.strictEqual(false, isNumeric("abc456")); | ||
}); | ||
it('isNumeric /w "789"', function () { | ||
assert.strictEqual(true, isNumeric("789")); | ||
}); | ||
it('isDigit /w "abc"', function () { | ||
assert.strictEqual(false, isDigit("abc")); | ||
}); | ||
it('isDigit /w "abc456"', function () { | ||
assert.strictEqual(false, isDigit("abc456")); | ||
}); | ||
it('isDigit /w "789"', function () { | ||
assert.strictEqual(true, isDigit("789")); | ||
}); | ||
}); | ||
@@ -46,14 +46,2 @@ var P = require('../nodash').install(GLOBAL); | ||
it('isNumeric /w "abc"', function () { | ||
assert.strictEqual(false, isNumeric("abc")); | ||
}); | ||
it('isNumeric /w "abc456"', function () { | ||
assert.strictEqual(false, isNumeric("abc456")); | ||
}); | ||
it('isNumeric /w "789"', function () { | ||
assert.strictEqual(true, isNumeric("789")); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
174771
109
4728
114