Comparing version 0.0.2 to 0.0.3
@@ -22,3 +22,2 @@ // gen-pasta.js | ||
function last(item) { | ||
var num = false | ||
if (typeof item === 'number') return +item.toString().split('').pop() | ||
@@ -29,3 +28,7 @@ if (typeof item === 'string') return item.split('').pop() | ||
return item | ||
} | ||
function flatten (arr) { | ||
if (Array.isArray(arr)) return arr.map(flatten).join('') | ||
return '' + arr | ||
} | ||
@@ -36,2 +39,3 @@ | ||
, last:last | ||
, flatten: flatten | ||
, arrify: arrify | ||
@@ -38,0 +42,0 @@ , combine: combine |
{ "name": "gen-pasta" | ||
, "version": "0.0.2" | ||
, "version": "0.0.3" | ||
, "author": "Nick Niemeir <nick.niemeir@gmail.com> (http://nrn.io)" | ||
@@ -4,0 +4,0 @@ , "main": "gen-pasta.js" |
@@ -15,1 +15,14 @@ #General Pasta | ||
##combine(obj1, obj2) | ||
Add everything from obj2 into obj1 and return obj1. | ||
##last(item) | ||
Attempt to return the last element from item, whatever | ||
item might be. | ||
##flatten(arr) | ||
Steamrolls nested arrays into a string. | ||
@@ -5,3 +5,3 @@ var p = require('../gen-pasta')() | ||
test('General', function (t) { | ||
t.plan(9) | ||
t.plan(12) | ||
@@ -31,4 +31,7 @@ t.doesNotThrow(p.log, 'Log does not throw') | ||
t.equal(obj2.foo, undefined, 'a stays the same') | ||
t.equal(p.flatten([ 'a', 'b', 'c' ]), 'abc', 'Flatten Normal') | ||
t.equal(p.flatten(1), '1', 'Flatten nothing') | ||
t.equal(p.flatten([1, [2, [3, [4, [5 ]]]]]), '12345', 'Flatten Nest') | ||
}) | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3868
61
28