1 | var N = require('libnested')
|
2 |
|
3 | function isFunction (f) {
|
4 | return typeof f === 'function'
|
5 | }
|
6 |
|
7 | function isTrue (b) {
|
8 | return b === true
|
9 | }
|
10 |
|
11 | function isGives (o) {
|
12 | return isString(o) || N.each(o, isTrue)
|
13 | }
|
14 |
|
15 | function isType (t) {
|
16 | return ({map: true, first: true, reduce: true})[t]
|
17 | }
|
18 |
|
19 | function isNeeds (n) {
|
20 | return N.each(n, isType)
|
21 | }
|
22 |
|
23 | function isModule (m) {
|
24 | return m && isFunction(m.create) && isGives(m.gives) && (!m.needs || isNeeds(m.needs))
|
25 | }
|
26 |
|
27 | function isString (s) {
|
28 | return typeof s === 'string'
|
29 | }
|
30 |
|
31 | module.exports = isModule
|