| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1279adc commit 1b434e0
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,6 @@ const internalUtil = require('internal/util'); | |||
| 6 | 6 | const binding = process.binding('util'); | |
| 7 | 7 | ||
| 8 | 8 | const isError = internalUtil.isError; | |
| 9 | - const objectToString = internalUtil.objectToString; | ||
| 10 | 9 | ||
| 11 | 10 | var Debug; | |
| 12 | 11 | ||
@@ -305,7 +304,7 @@ function formatValue(ctx, value, recurseTimes) { | |||
| 305 | 304 | braces = ['[', ']']; | |
| 306 | 305 | empty = value.length === 0; | |
| 307 | 306 | formatter = formatArray; | |
| 308 | - } else if (objectToString(value) === '[object Set]') { | ||
| 307 | + } else if (binding.isSet(value)) { | ||
| 309 | 308 | braces = ['{', '}']; | |
| 310 | 309 | // With `showHidden`, `length` will display as a hidden property for | |
| 311 | 310 | // arrays. For consistency's sake, do the same for `size`, even though this | |
@@ -314,7 +313,7 @@ function formatValue(ctx, value, recurseTimes) { | |||
| 314 | 313 | keys.unshift('size'); | |
| 315 | 314 | empty = value.size === 0; | |
| 316 | 315 | formatter = formatSet; | |
| 317 | - } else if (objectToString(value) === '[object Map]') { | ||
| 316 | + } else if (binding.isMap(value)) { | ||
| 318 | 317 | braces = ['{', '}']; | |
| 319 | 318 | // Ditto. | |
| 320 | 319 | if (ctx.showHidden) | |
@@ -673,7 +672,7 @@ function isUndefined(arg) { | |||
| 673 | 672 | exports.isUndefined = isUndefined; | |
| 674 | 673 | ||
| 675 | 674 | function isRegExp(re) { | |
| 676 | - return objectToString(re) === '[object RegExp]'; | ||
| 675 | + return binding.isRegExp(re); | ||
| 677 | 676 | } | |
| 678 | 677 | exports.isRegExp = isRegExp; | |
| 679 | 678 | ||
@@ -683,7 +682,7 @@ function isObject(arg) { | |||
| 683 | 682 | exports.isObject = isObject; | |
| 684 | 683 | ||
| 685 | 684 | function isDate(d) { | |
| 686 | - return objectToString(d) === '[object Date]'; | ||
| 685 | + return binding.isDate(d); | ||
| 687 | 686 | } | |
| 688 | 687 | exports.isDate = isDate; | |
| 689 | 688 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,12 +13,37 @@ using v8::Object; | |||
| 13 | 13 | using v8::String; | |
| 14 | 14 | using v8::Value; | |
| 15 | 15 | ||
| 16 | + | ||
| 17 | + static void IsRegExp(const FunctionCallbackInfo<Value>& args) { | ||
| 18 | + CHECK_EQ(1, args.Length()); | ||
| 19 | + args.GetReturnValue().Set(args[0]->IsRegExp()); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + static void IsDate(const FunctionCallbackInfo<Value>& args) { | ||
| 24 | + CHECK_EQ(1, args.Length()); | ||
| 25 | + args.GetReturnValue().Set(args[0]->IsDate()); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + | ||
| 29 | + static void IsMap(const FunctionCallbackInfo<Value>& args) { | ||
| 30 | + CHECK_EQ(1, args.Length()); | ||
| 31 | + args.GetReturnValue().Set(args[0]->IsMap()); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + | ||
| 16 | 35 | static void IsMapIterator(const FunctionCallbackInfo<Value>& args) { | |
| 17 | 36 | CHECK_EQ(1, args.Length()); | |
| 18 | 37 | args.GetReturnValue().Set(args[0]->IsMapIterator()); | |
| 19 | 38 | } | |
| 20 | 39 | ||
| 21 | 40 | ||
| 41 | + static void IsSet(const FunctionCallbackInfo<Value>& args) { | ||
| 42 | + CHECK_EQ(1, args.Length()); | ||
| 43 | + args.GetReturnValue().Set(args[0]->IsSet()); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + | ||
| 22 | 47 | static void IsSetIterator(const FunctionCallbackInfo<Value>& args) { | |
| 23 | 48 | CHECK_EQ(1, args.Length()); | |
| 24 | 49 | args.GetReturnValue().Set(args[0]->IsSetIterator()); | |
@@ -50,7 +75,11 @@ void Initialize(Local<Object> target, | |||
| 50 | 75 | Local<Value> unused, | |
| 51 | 76 | Local<Context> context) { | |
| 52 | 77 | Environment* env = Environment::GetCurrent(context); | |
| 78 | + env->SetMethod(target, "isRegExp", IsRegExp); | ||
| 79 | + env->SetMethod(target, "isDate", IsDate); | ||
| 80 | + env->SetMethod(target, "isMap", IsMap); | ||
| 53 | 81 | env->SetMethod(target, "isMapIterator", IsMapIterator); | |
| 82 | + env->SetMethod(target, "isSet", IsSet); | ||
| 54 | 83 | env->SetMethod(target, "isSetIterator", IsSetIterator); | |
| 55 | 84 | env->SetMethod(target, "isPromise", IsPromise); | |
| 56 | 85 | env->SetMethod(target, "getHiddenValue", GetHiddenValue); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments