22var assert = require ( 'assert' )
33var clone = require ( 'clone' )
44var fs = require ( 'co-fs-extra' )
5- var is = require ( 'is' )
65var matter = require ( 'gray-matter' )
76var Mode = require ( 'stat-mode' )
87var path = require ( 'path' )
@@ -25,7 +24,11 @@ rm = thunkify(rm)
2524 * Helpers
2625 */
2726
28- var absolute = function ( s ) { return path . resolve ( s ) === s }
27+ var absolute = function ( s ) { return path . resolve ( s ) === s }
28+ var isBoolean = function ( b ) { return typeof b === 'boolean' }
29+ var isNumber = function ( n ) { return typeof n === 'number' && ! Number . isNaN ( n ) }
30+ var isObject = function ( o ) { return o !== null && typeof o === 'object' }
31+ var isString = function ( s ) { return typeof s === 'string' }
2932
3033
3134/**
@@ -75,7 +78,7 @@ Metalsmith.prototype.use = function(plugin){
7578
7679Metalsmith . prototype . directory = function ( directory ) {
7780 if ( ! arguments . length ) return path . resolve ( this . _directory )
78- assert ( is . string ( directory ) , 'You must pass a directory path string.' )
81+ assert ( isString ( directory ) , 'You must pass a directory path string.' )
7982 this . _directory = directory
8083 return this
8184}
@@ -89,7 +92,7 @@ Metalsmith.prototype.directory = function(directory){
8992
9093Metalsmith . prototype . metadata = function ( metadata ) {
9194 if ( ! arguments . length ) return this . _metadata
92- assert ( is . object ( metadata ) , 'You must pass a metadata object.' )
95+ assert ( isObject ( metadata ) , 'You must pass a metadata object.' )
9396 this . _metadata = clone ( metadata )
9497 return this
9598}
@@ -103,7 +106,7 @@ Metalsmith.prototype.metadata = function(metadata){
103106
104107Metalsmith . prototype . source = function ( path ) {
105108 if ( ! arguments . length ) return this . path ( this . _source )
106- assert ( is . string ( path ) , 'You must pass a source path string.' )
109+ assert ( isString ( path ) , 'You must pass a source path string.' )
107110 this . _source = path
108111 return this
109112}
@@ -117,7 +120,7 @@ Metalsmith.prototype.source = function(path){
117120
118121Metalsmith . prototype . destination = function ( path ) {
119122 if ( ! arguments . length ) return this . path ( this . _destination )
120- assert ( is . string ( path ) , 'You must pass a destination path string.' )
123+ assert ( isString ( path ) , 'You must pass a destination path string.' )
121124 this . _destination = path
122125 return this
123126}
@@ -131,7 +134,7 @@ Metalsmith.prototype.destination = function(path){
131134
132135Metalsmith . prototype . concurrency = function ( max ) {
133136 if ( ! arguments . length ) return this . _concurrency
134- assert ( is . number ( max ) , 'You must pass a number for concurrency.' )
137+ assert ( isNumber ( max ) , 'You must pass a number for concurrency.' )
135138 this . _concurrency = max
136139 return this
137140}
@@ -144,7 +147,7 @@ Metalsmith.prototype.concurrency = function(max){
144147 */
145148Metalsmith . prototype . clean = function ( clean ) {
146149 if ( ! arguments . length ) return this . _clean
147- assert ( is . boolean ( clean ) , 'You must pass a boolean.' )
150+ assert ( isBoolean ( clean ) , 'You must pass a boolean.' )
148151 this . _clean = clean
149152 return this
150153}
@@ -158,7 +161,7 @@ Metalsmith.prototype.clean = function(clean){
158161
159162Metalsmith . prototype . frontmatter = function ( frontmatter ) {
160163 if ( ! arguments . length ) return this . _frontmatter
161- assert ( is . boolean ( frontmatter ) , 'You must pass a boolean.' )
164+ assert ( isBoolean ( frontmatter ) , 'You must pass a boolean.' )
162165 this . _frontmatter = frontmatter
163166 return this
164167}
0 commit comments