added *ignore stuff

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-09-28 15:47:58 +03:00
parent d610447daa
commit d02a5f6053
3 changed files with 22 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.*
*.sw[po]
*.vim
node_modules/*

5
.npmignore Normal file
View File

@ -0,0 +1,5 @@
.npm*
*.vim
*.sw[po]
.git
npm-debug.log

View File

@ -43,19 +43,32 @@ Target use-cases:
sum( [1, [2, 3], 4, [[5], 6]] ) // -> 21
```
For reference here is a *recursive* `.reduce(..)` example:
```javascript
function sumr(l){
return l.reduce(function(r, e){
return r + (e instanceof Array ?
sumr(e)
: e) }, 0) }
sumr( [1, [2, 3], 4, [[5], 6]] ) // -> 21
```
- Need to abort the recursion prematurelly:
```javascript
// check if structure contains 0...
var containsZero = walk(function(r, e, next, down, stop){
return e === 0 ?
// target found, abort the search...
stop(true)
: e instanceof Array ?
// breadth-first walk...
!!next(...e)
: r }, false)
containsZero( [1, [2, 0], 4, [[5], 6]] ) // -> true
containsZero( [1, [2, 5], 4, [[5], 6]] ) // -> false
```
See a more usefull search in [examples](#examples)...
## Installation and loading