Browse Source

Add Buffer as type to prevent react-native crash

master
michaelftout 5 years ago
parent
commit
b3ff64d834
  1. 2
      index.js
  2. 1
      native.js

2
index.js

@ -229,7 +229,7 @@ function compile (type) {
}
function typeforce (type, value, strict, surrogate) {
if (NATIVE.Function(type)) {
if (!NATIVE.Buffer(type) && NATIVE.Function(type)) {
if (type(value, strict)) return true
throw new TfTypeError(surrogate || type, value)

1
native.js

@ -6,6 +6,7 @@ var types = {
Number: function (value) { return typeof value === 'number' },
Object: function (value) { return typeof value === 'object' },
String: function (value) { return typeof value === 'string' },
Buffer: function (value) { return Buffer.isBuffer(value) },
'': function () { return true }
}

Loading…
Cancel
Save