Comparing version 0.1.0 to 0.2.0
17
index.js
@@ -8,7 +8,12 @@ 'use strict'; | ||
function Dekko(pattern, options) { | ||
const filenames = glob.sync(pattern, options); | ||
if (filenames.length === 0) { | ||
throw new Error(`There is not file that matches pattern \`${pattern}.\``); | ||
if (Array.isArray(pattern) && !options) { | ||
// Private | ||
this.filenames = pattern; | ||
} else { | ||
const filenames = glob.sync(pattern, options); | ||
if (filenames.length === 0) { | ||
throw new Error(`There is not file that matches pattern \`${pattern}\`.`); | ||
} | ||
this.filenames = filenames; | ||
} | ||
this.filenames = filenames; | ||
} | ||
@@ -52,2 +57,6 @@ | ||
}, | ||
filter(cond) { | ||
const filenames = this.filenames.filter(cond); | ||
return new Dekko(filenames); | ||
}, | ||
}); | ||
@@ -54,0 +63,0 @@ |
{ | ||
"name": "dekko", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "To test whether files and directory structure are valid.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -59,4 +59,8 @@ # dekko | ||
### .filter(cond): Object | ||
`.filter` works like `Array.prototype.filter`, and it return a new `dekko` object with filtered items. | ||
## License | ||
MIT |
@@ -76,2 +76,9 @@ 'use strict'; | ||
}); | ||
describe('#filter', () => { | ||
it('should work like Array.prototype.filter', () => { | ||
const o = $('test/fixtures/*').filter(filename => /a$/.test(filename)); | ||
assert.deepEqual(o.filenames, [ 'test/fixtures/a' ]); | ||
}); | ||
}); | ||
}); |
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
8909
126
66