-
-
Notifications
You must be signed in to change notification settings - Fork 35k
Util(.is*) Deprecations #1301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Util(.is*) Deprecations #1301
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -505,49 +505,60 @@ const isArray = exports.isArray = Array.isArray; | |
| function isBoolean(arg) { | ||
| return typeof arg === 'boolean'; | ||
| } | ||
| exports.isBoolean = isBoolean; | ||
| exports.isBoolean = deprecate(isBoolean, | ||
| 'util.isBoolean is deprecated, please use a user-land alternative.'); | ||
|
|
||
| function isNull(arg) { | ||
| return arg === null; | ||
| } | ||
| exports.isNull = isNull; | ||
| exports.isNull = deprecate(isNull, | ||
| 'util.isNull is deprecated, please use a user-land alternative.'); | ||
|
|
||
| function isNullOrUndefined(arg) { | ||
| return arg === null || arg === undefined; | ||
| } | ||
| exports.isNullOrUndefined = isNullOrUndefined; | ||
| exports.isNullOrUndefined = deprecate(isNullOrUndefined, | ||
| 'util.isNullOrUndefined is deprecated, please use a user-land alternative.'); | ||
|
|
||
| function isNumber(arg) { | ||
| return typeof arg === 'number'; | ||
| } | ||
| exports.isNumber = isNumber; | ||
| exports.isNumber = deprecate(isNumber, | ||
| 'util.isNumber is deprecated, please use a user-land alternative.'); | ||
|
|
||
| function isString(arg) { | ||
| return typeof arg === 'string'; | ||
| } | ||
| exports.isString = isString; | ||
| exports.isString = deprecate(isString, | ||
| 'util.isSrting is deprecated, please use a user-land alternative.'); | ||
|
|
||
| function isSymbol(arg) { | ||
| return typeof arg === 'symbol'; | ||
| } | ||
| exports.isSymbol = isSymbol; | ||
| exports.isSymbol = deprecate(isSymbol, | ||
| 'util.isSymbol is deprecated, please use a user-land alternative.'); | ||
|
|
||
| function isUndefined(arg) { | ||
| return arg === undefined; | ||
| } | ||
| exports.isUndefined = isUndefined; | ||
| exports.isUndefined = deprecate(isUndefined, | ||
| 'util.isUndefined is deprecated, please use a user-land alternative.'); | ||
|
|
||
| // note: the isRegExp function is still used here in util | ||
| function isRegExp(re) { | ||
| return re !== null && typeof re === 'object' && | ||
| objectToString(re) === '[object RegExp]'; | ||
| } | ||
| exports.isRegExp = isRegExp; | ||
| exports.isRegExp = deprecate(isRegExp, | ||
| 'util.isRegExp is deprecated, please use a user-land alternative.'); | ||
|
|
||
| function isObject(arg) { | ||
| return arg !== null && typeof arg === 'object'; | ||
| } | ||
| exports.isObject = isObject; | ||
| exports.isObject = deprecate(isObject, | ||
| 'util.isObject is deprecated, please use a user-land alternative.'); | ||
|
|
||
| // still used in assert and fs | ||
| function isDate(d) { | ||
| return d !== null && typeof d === 'object' && | ||
| objectToString(d) === '[object Date]'; | ||
|
|
@@ -558,13 +569,16 @@ function isError(e) { | |
| return e !== null && typeof e === 'object' && | ||
| (objectToString(e) === '[object Error]' || e instanceof Error); | ||
| } | ||
| exports.isError = isError; | ||
| exports.isError = deprecate(isError, | ||
| 'util.isError is deprecated, please use a user-land alternative.'); | ||
|
|
||
| function isFunction(arg) { | ||
| return typeof arg === 'function'; | ||
| } | ||
| exports.isFunction = isFunction; | ||
| exports.isFunction = deprecate(isFunction, | ||
| 'util.isFunction is deprecated, please use a user-land alternative.'); | ||
|
|
||
| // still used in assert, domain, and smalloc | ||
| function isPrimitive(arg) { | ||
| return arg === null || | ||
| typeof arg !== 'object' && typeof arg !== 'function'; | ||
|
|
@@ -574,7 +588,8 @@ exports.isPrimitive = isPrimitive; | |
| function isBuffer(arg) { | ||
| return arg instanceof Buffer; | ||
| } | ||
| exports.isBuffer = isBuffer; | ||
| exports.isBuffer = deprecate(isBuffer, | ||
| 'util.isBuffer is deprecated, please use a user-land alternative.'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should recommend using
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ooops. Honestly, I don't even know why we use
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure why That said, Eventually, I can just return a proper
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @trevnorris?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Once upon a time there existed the SlowBuffer class. It didn't inherit from Buffer so instances were buffers but not SlowBuffer still exists but it's more or less obsolete. It inherits from Buffer now so As to why it didn't before, I don't exactly remember but it was probably accidental. SlowBuffer was an implementation detail - it was the backing store for normal buffers - and not something users normally interacted with directly.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @bnoordhuis. That was before my time. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, should I use
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can also use Buffer.isBuffer which is not deprecated.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are exactly the same.
|
||
|
|
||
| function objectToString(o) { | ||
| return Object.prototype.toString.call(o); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't the
objectToStringbe sufficient here? Why do we need the other two checks?