Skip to content
This repository was archived by the owner on Dec 2, 2024. It is now read-only.
/ level-js Public archive

Commit 53a0c8d

Browse files
committed
Merge pull request #7 from juliangruber/isbuffer
use isbuffer
2 parents 36d744d + 4bb4024 commit 53a0c8d

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

index.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var IDB = require('idb-wrapper')
44
var AbstractLevelDOWN = require('abstract-leveldown').AbstractLevelDOWN
55
var util = require('util')
66
var Iterator = require('./iterator')
7+
var isBuffer = require('isbuffer')
78

89
function Level(location) {
910
if (!(this instanceof Level)) return new Level(location)
@@ -67,20 +68,7 @@ Level.prototype._approximateSize = function() {
6768
throw new Error('Not implemented')
6869
}
6970

70-
var isBuffer = Level.prototype._isBuffer = function (buf) {
71-
// TODO is there a better way to check this?
72-
if (buf instanceof ArrayBuffer) return true
73-
if (buf instanceof Int8Array) return true
74-
if (buf instanceof Int16Array) return true
75-
if (buf instanceof Int32Array) return true
76-
if (buf instanceof Uint8Array) return true
77-
if (buf instanceof Uint16Array) return true
78-
if (buf instanceof Uint32Array) return true
79-
if (buf instanceof Uint8ClampedArray) return true
80-
if (buf instanceof Float32Array) return true
81-
if (buf instanceof Float64Array) return true
82-
return false
83-
}
71+
Level.prototype._isBuffer = isBuffer
8472

8573
var checkKeyValue = Level.prototype._checkKeyValue = function (obj, type) {
8674
if (obj === null || obj === undefined)
@@ -106,4 +94,4 @@ function StringToArrayBuffer(str) {
10694
bufView[i] = str.charCodeAt(i)
10795
}
10896
return buf
109-
}
97+
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"dependencies": {
2525
"idb-wrapper": "git://github.com/maxogden/IDBWrapper.git#autoContinueOption",
2626
"abstract-leveldown": "~0.3.0",
27-
"levelup": "git://github.com/rvagg/node-levelup.git#0.9-wip"
27+
"levelup": "git://github.com/rvagg/node-levelup.git#0.9-wip",
28+
"isbuffer": "0.0.0"
2829
}
2930
}

0 commit comments

Comments
 (0)