Skip to content

Commit

Permalink
stream, bugfix: fix buffer type check.
Browse files Browse the repository at this point in the history
  • Loading branch information
xicilion committed Jan 19, 2018
1 parent 44a3e84 commit 3f12dfe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion fibjs/scripts/stream.js
Expand Up @@ -54,7 +54,7 @@ try {

if (!Stream._isUint8Array) {
Stream._isUint8Array = function _isUint8Array(obj) {
return Object.prototype.toString.call(obj) === '[object Uint8Array]';
return Object.prototype.toString.call(obj) === '[object Uint8Array]' || Buffer.isBuffer(obj);
};
}

Expand Down
41 changes: 21 additions & 20 deletions fibjs/src/base/opt_tools.cpp
Expand Up @@ -6240,26 +6240,27 @@ const char* opt_tools[] = {
"\x5f\x69\x73\x55\x69\x6e\x74\x38\x41\x72\x72\x61\x79\x28\x6f\x62\x6a\x29\x20\x7b\x0a\x20\x20\x20\x20\x72\x65\x74\x75\x72"
"\x6e\x20\x4f\x62\x6a\x65\x63\x74\x2e\x70\x72\x6f\x74\x6f\x74\x79\x70\x65\x2e\x74\x6f\x53\x74\x72\x69\x6e\x67\x2e\x63\x61"
"\x6c\x6c\x28\x6f\x62\x6a\x29\x20\x3d\x3d\x3d\x20\x27\x5b\x6f\x62\x6a\x65\x63\x74\x20\x55\x69\x6e\x74\x38\x41\x72\x72\x61"
"\x79\x5d\x27\x3b\x0a\x20\x20\x7d\x3b\x0a\x7d\x0a\x0a\x63\x6f\x6e\x73\x74\x20\x76\x65\x72\x73\x69\x6f\x6e\x20\x3d\x20\x70"
"\x72\x6f\x63\x65\x73\x73\x2e\x76\x65\x72\x73\x69\x6f\x6e\x2e\x73\x75\x62\x73\x74\x72\x28\x31\x29\x2e\x73\x70\x6c\x69\x74"
"\x28\x27\x2e\x27\x29\x3b\x0a\x69\x66\x20\x28\x76\x65\x72\x73\x69\x6f\x6e\x5b\x30\x5d\x20\x3d\x3d\x3d\x20\x30\x20\x26\x26"
"\x20\x76\x65\x72\x73\x69\x6f\x6e\x5b\x31\x5d\x20\x3c\x20\x31\x32\x29\x20\x7b\x0a\x20\x20\x53\x74\x72\x65\x61\x6d\x2e\x5f"
"\x75\x69\x6e\x74\x38\x41\x72\x72\x61\x79\x54\x6f\x42\x75\x66\x66\x65\x72\x20\x3d\x20\x42\x75\x66\x66\x65\x72\x3b\x0a\x7d"
"\x20\x65\x6c\x73\x65\x20\x7b\x0a\x20\x20\x74\x72\x79\x20\x7b\x0a\x20\x20\x20\x20\x63\x6f\x6e\x73\x74\x20\x69\x6e\x74\x65"
"\x72\x6e\x61\x6c\x42\x75\x66\x66\x65\x72\x20\x3d\x20\x72\x65\x71\x75\x69\x72\x65\x28\x27\x69\x6e\x74\x65\x72\x6e\x61\x6c"
"\x2f\x62\x75\x66\x66\x65\x72\x27\x29\x3b\x0a\x20\x20\x20\x20\x53\x74\x72\x65\x61\x6d\x2e\x5f\x75\x69\x6e\x74\x38\x41\x72"
"\x72\x61\x79\x54\x6f\x42\x75\x66\x66\x65\x72\x20\x3d\x20\x66\x75\x6e\x63\x74\x69\x6f\x6e\x20\x5f\x75\x69\x6e\x74\x38\x41"
"\x72\x72\x61\x79\x54\x6f\x42\x75\x66\x66\x65\x72\x28\x63\x68\x75\x6e\x6b\x29\x20\x7b\x0a\x20\x20\x20\x20\x20\x20\x72\x65"
"\x74\x75\x72\x6e\x20\x6e\x65\x77\x20\x69\x6e\x74\x65\x72\x6e\x61\x6c\x42\x75\x66\x66\x65\x72\x2e\x46\x61\x73\x74\x42\x75"
"\x66\x66\x65\x72\x28\x63\x68\x75\x6e\x6b\x2e\x62\x75\x66\x66\x65\x72\x2c\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x63\x68\x75"
"\x6e\x6b\x2e\x62\x79\x74\x65\x4f\x66\x66\x73\x65\x74\x2c\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x63\x68\x75\x6e\x6b\x2e\x62"
"\x79\x74\x65\x4c\x65\x6e\x67\x74\x68\x29\x3b\x0a\x20\x20\x20\x20\x7d\x3b\x0a\x20\x20\x7d\x20\x63\x61\x74\x63\x68\x20\x28"
"\x65\x29\x20\x7b\x7d\x0a\x0a\x20\x20\x69\x66\x20\x28\x21\x53\x74\x72\x65\x61\x6d\x2e\x5f\x75\x69\x6e\x74\x38\x41\x72\x72"
"\x61\x79\x54\x6f\x42\x75\x66\x66\x65\x72\x29\x20\x7b\x0a\x20\x20\x20\x20\x53\x74\x72\x65\x61\x6d\x2e\x5f\x75\x69\x6e\x74"
"\x38\x41\x72\x72\x61\x79\x54\x6f\x42\x75\x66\x66\x65\x72\x20\x3d\x20\x66\x75\x6e\x63\x74\x69\x6f\x6e\x20\x5f\x75\x69\x6e"
"\x74\x38\x41\x72\x72\x61\x79\x54\x6f\x42\x75\x66\x66\x65\x72\x28\x63\x68\x75\x6e\x6b\x29\x20\x7b\x0a\x20\x20\x20\x20\x20"
"\x20\x72\x65\x74\x75\x72\x6e\x20\x42\x75\x66\x66\x65\x72\x2e\x70\x72\x6f\x74\x6f\x74\x79\x70\x65\x2e\x73\x6c\x69\x63\x65"
"\x2e\x63\x61\x6c\x6c\x28\x63\x68\x75\x6e\x6b\x29\x3b\x0a\x20\x20\x20\x20\x7d\x3b\x0a\x20\x20\x7d\x0a\x7d",
"\x79\x5d\x27\x20\x7c\x7c\x20\x42\x75\x66\x66\x65\x72\x2e\x69\x73\x42\x75\x66\x66\x65\x72\x28\x6f\x62\x6a\x29\x3b\x0a\x20"
"\x20\x7d\x3b\x0a\x7d\x0a\x0a\x63\x6f\x6e\x73\x74\x20\x76\x65\x72\x73\x69\x6f\x6e\x20\x3d\x20\x70\x72\x6f\x63\x65\x73\x73"
"\x2e\x76\x65\x72\x73\x69\x6f\x6e\x2e\x73\x75\x62\x73\x74\x72\x28\x31\x29\x2e\x73\x70\x6c\x69\x74\x28\x27\x2e\x27\x29\x3b"
"\x0a\x69\x66\x20\x28\x76\x65\x72\x73\x69\x6f\x6e\x5b\x30\x5d\x20\x3d\x3d\x3d\x20\x30\x20\x26\x26\x20\x76\x65\x72\x73\x69"
"\x6f\x6e\x5b\x31\x5d\x20\x3c\x20\x31\x32\x29\x20\x7b\x0a\x20\x20\x53\x74\x72\x65\x61\x6d\x2e\x5f\x75\x69\x6e\x74\x38\x41"
"\x72\x72\x61\x79\x54\x6f\x42\x75\x66\x66\x65\x72\x20\x3d\x20\x42\x75\x66\x66\x65\x72\x3b\x0a\x7d\x20\x65\x6c\x73\x65\x20"
"\x7b\x0a\x20\x20\x74\x72\x79\x20\x7b\x0a\x20\x20\x20\x20\x63\x6f\x6e\x73\x74\x20\x69\x6e\x74\x65\x72\x6e\x61\x6c\x42\x75"
"\x66\x66\x65\x72\x20\x3d\x20\x72\x65\x71\x75\x69\x72\x65\x28\x27\x69\x6e\x74\x65\x72\x6e\x61\x6c\x2f\x62\x75\x66\x66\x65"
"\x72\x27\x29\x3b\x0a\x20\x20\x20\x20\x53\x74\x72\x65\x61\x6d\x2e\x5f\x75\x69\x6e\x74\x38\x41\x72\x72\x61\x79\x54\x6f\x42"
"\x75\x66\x66\x65\x72\x20\x3d\x20\x66\x75\x6e\x63\x74\x69\x6f\x6e\x20\x5f\x75\x69\x6e\x74\x38\x41\x72\x72\x61\x79\x54\x6f"
"\x42\x75\x66\x66\x65\x72\x28\x63\x68\x75\x6e\x6b\x29\x20\x7b\x0a\x20\x20\x20\x20\x20\x20\x72\x65\x74\x75\x72\x6e\x20\x6e"
"\x65\x77\x20\x69\x6e\x74\x65\x72\x6e\x61\x6c\x42\x75\x66\x66\x65\x72\x2e\x46\x61\x73\x74\x42\x75\x66\x66\x65\x72\x28\x63"
"\x68\x75\x6e\x6b\x2e\x62\x75\x66\x66\x65\x72\x2c\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x63\x68\x75\x6e\x6b\x2e\x62\x79\x74"
"\x65\x4f\x66\x66\x73\x65\x74\x2c\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x63\x68\x75\x6e\x6b\x2e\x62\x79\x74\x65\x4c\x65\x6e"
"\x67\x74\x68\x29\x3b\x0a\x20\x20\x20\x20\x7d\x3b\x0a\x20\x20\x7d\x20\x63\x61\x74\x63\x68\x20\x28\x65\x29\x20\x7b\x7d\x0a"
"\x0a\x20\x20\x69\x66\x20\x28\x21\x53\x74\x72\x65\x61\x6d\x2e\x5f\x75\x69\x6e\x74\x38\x41\x72\x72\x61\x79\x54\x6f\x42\x75"
"\x66\x66\x65\x72\x29\x20\x7b\x0a\x20\x20\x20\x20\x53\x74\x72\x65\x61\x6d\x2e\x5f\x75\x69\x6e\x74\x38\x41\x72\x72\x61\x79"
"\x54\x6f\x42\x75\x66\x66\x65\x72\x20\x3d\x20\x66\x75\x6e\x63\x74\x69\x6f\x6e\x20\x5f\x75\x69\x6e\x74\x38\x41\x72\x72\x61"
"\x79\x54\x6f\x42\x75\x66\x66\x65\x72\x28\x63\x68\x75\x6e\x6b\x29\x20\x7b\x0a\x20\x20\x20\x20\x20\x20\x72\x65\x74\x75\x72"
"\x6e\x20\x42\x75\x66\x66\x65\x72\x2e\x70\x72\x6f\x74\x6f\x74\x79\x70\x65\x2e\x73\x6c\x69\x63\x65\x2e\x63\x61\x6c\x6c\x28"
"\x63\x68\x75\x6e\x6b\x29\x3b\x0a\x20\x20\x20\x20\x7d\x3b\x0a\x20\x20\x7d\x0a\x7d",
NULL
};
}

0 comments on commit 3f12dfe

Please sign in to comment.