Skip to content

Commit 54dba0c

Browse files
committed
refactor: Remove is
If we expected to receive a barrage of assorted arguments to functions, we might need `is`. But for Metalsmith, it’s overkill. People know to pass a string for directories. People know what a number is. :P
1 parent f231064 commit 54dba0c

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

lib/index.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
var assert = require('assert')
33
var clone = require('clone')
44
var fs = require('co-fs-extra')
5-
var is = require('is')
65
var matter = require('gray-matter')
76
var Mode = require('stat-mode')
87
var 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

7679
Metalsmith.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

9093
Metalsmith.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

104107
Metalsmith.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

118121
Metalsmith.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

132135
Metalsmith.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
*/
145148
Metalsmith.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

159162
Metalsmith.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
}

package-lock.json

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"commander": "^2.6.0",
2727
"gray-matter": "^2.1.0",
2828
"has-generators": "^1.0.1",
29-
"is": "^3.1.0",
3029
"is-utf8": "~0.2.0",
3130
"recursive-readdir": "^2.1.0",
3231
"rimraf": "^2.2.8",

0 commit comments

Comments
 (0)