-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathindex.js
73 lines (68 loc) · 1.85 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
'use strict';
module.exports = {};
/*
* balancedParentheses
*
* Takes an input string and returns true or false depending on if the string
* has balanced parentheses.
*
* Eg:
*
* input: '(x + y)'
* returns: true
*
* input: '(x + y'
* returns: false
*
* input: 'foo bar baz'
* returns: false
*
* input: ''
* returns: false
*/
module.exports.balancedParentheses = require( './src/balancedParentheses.js' );
/*
* finder
*
* Takes an input and a test function and returns any values in
* the input that pass the test.
*
* Eg:
*
* input: [ 'ant', 'baby', [ 'apple', 'banana', 'carrot' ], { foo: 'aardvark' }, 'allegory' ]
* test: value => /^a/i.test( value )
* returns: [ 'ant', 'allegory' ]
*
*/
module.exports.finder = require( './src/finder.js' );
/*
* deepFinder
*
* Takes an input and a test function and returns any values
* in the input *recursively* that pass the test.
*
* Eg:
*
* input: [ 'ant', 'baby', [ 'apple', 'banana', 'carrot' ], { foo: 'aardvark' }, 'allegory' ]
* test: value => /^a/i.test( value )
* returns: [ 'ant', 'apple', 'aardvark', 'allegory' ]
*
*/
module.exports.deepFinder = require( './src/deepFinder.js' );
/*
* fizzBuzz
*
* Takes an input length and returns an array of the specified length
* where the values are:
* 1) the index + 1, eg: [ 1, 2 ], array[ 0 ] === 1, array[ 1 ] === 2
* 2) values that would be multiples of 3 are replaced with 'fizz', eg: [ 1, 2, 'fizz' ]
* 3) values that would be multiples of 5 are replaced with 'buzz', eg: [ 1, 2, 'fizz', 4, 'buzz' ]
* 4) values that would be multiples of both 3 and 5 are replaced with 'fizzbuzz', eg: [ 1, 2, 'fizz', ... 14, 'fizzbuzz' ]
*
* Eg:
*
* input: 10
* returns: [ 1, 2, 'fizz', 4, 'buzz', 'fizz', 7, 8, 'fizz', 'buzz' ]
*
*/
module.exports.fizzBuzz = require( './src/fizzBuzz.js' );