Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function split (matcher, mapper, options) {
mapper = matcher
matcher = /\r?\n/
// If options is only argument.
} else if (typeof matcher === 'object' && !(matcher instanceof RegExp)) {
} else if (typeof matcher === 'object' && !(matcher instanceof RegExp) && !matcher[Symbol.split]) {
options = matcher
matcher = /\r?\n/
}
Expand Down
17 changes: 17 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,20 @@ test('mapper throws on transform', function (t) {
input.write('\n')
input.end('b')
})

test('supports Symbol.split', function (t) {
t.plan(2)

const input = split({
[Symbol.split] (str) {
return str.split('~')
}
})

input.pipe(strcb(function (err, list) {
t.error(err)
t.deepEqual(list, ['hello', 'world'])
}))

input.end('hello~world')
})