We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 00a7f57 commit cbfb25dCopy full SHA for cbfb25d
lib/bson/binary.js
@@ -30,6 +30,16 @@ if (typeof global !== 'undefined') {
30
function Binary(buffer, subType) {
31
if (!(this instanceof Binary)) return new Binary(buffer, subType);
32
33
+ if (
34
+ buffer != null &&
35
+ !(typeof buffer === 'string') &&
36
+ !Buffer.isBuffer(buffer) &&
37
+ !(buffer instanceof Uint8Array) &&
38
+ !Array.isArray(buffer)
39
+ ) {
40
+ throw new Error('only String, Buffer, Uint8Array or Array accepted');
41
+ }
42
+
43
this._bsontype = 'Binary';
44
45
if (buffer instanceof Number) {
0 commit comments