-
-
Notifications
You must be signed in to change notification settings - Fork 20
feat(util.is()
): introduce
#119
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
21c272e
22c84fe
4a5d5f0
4ca8c17
5f7369a
b52adfd
afbc8fd
7169e83
e9df057
f679a55
09a7d8d
82cc1f4
cb95073
3e07153
1663c77
90ab2ca
f1a091f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -47,7 +47,7 @@ const replacements = new Map<string, (arg: string) => string>([ | |||||
['isError', (arg: string) => `Error.isError(${arg})`], | ||||||
['isFunction', (arg: string) => `typeof ${arg} === 'function'`], | ||||||
['isNull', (arg: string) => `${arg} === null`], | ||||||
['isNullOrUndefined', (arg: string) => `${arg} == null`], | ||||||
['isNullOrUndefined', (arg: string) => `${arg} === null || ${arg} === undefined`], | ||||||
['isNumber', (arg: string) => `typeof ${arg} === 'number'`], | ||||||
['isObject', (arg: string) => `${arg} && typeof ${arg} === 'object'`], | ||||||
['isPrimitive', (arg: string) => `Object(${arg}) !== ${arg}`], | ||||||
|
@@ -69,7 +69,7 @@ const replacements = new Map<string, (arg: string) => string>([ | |||||
* 5. util.isError() → value instanceof Error | ||||||
* 6. util.isFunction() → typeof value === 'function' | ||||||
* 7. util.isNull() → value === null | ||||||
* 8. util.isNullOrUndefined() → value == null | ||||||
* 8. util.isNullOrUndefined() → value === null || value === undefined | ||||||
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. very nit since it's a comment:
Suggested change
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. 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. Yes, I understand :) null == null // true
undefined == null // true
false == null // false
0 == null // false
'' == null // false 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. The difference is in 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. so what should I do ? 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 don't understand @ljharb's comment, so I'm not sure. But this thread was based on a nit—it's not blocking. The blocking issue is supporting dynamic import. 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.
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. Ah. I think we can ignore that extreme edge-case. |
||||||
* 9. util.isNumber() → typeof value === 'number' | ||||||
* 10. util.isObject() → typeof value === 'object' && value !== null | ||||||
* 11. util.isPrimitive() → value !== Object(value) | ||||||
|
@@ -207,7 +207,9 @@ export default function transform(root: SgRoot): string | null { | |||||
for (const requireNode of requireStatements) { | ||||||
const objectPattern = requireNode.find({ rule: { kind: 'object_pattern' } }); | ||||||
if (objectPattern) { | ||||||
const shorthand = objectPattern.findAll({ rule: { kind: 'shorthand_property_identifier_pattern' } }); | ||||||
const shorthand = objectPattern.findAll({ | ||||||
rule: { kind: 'shorthand_property_identifier_pattern' } | ||||||
}); | ||||||
const pairs = objectPattern.findAll({ rule: { kind: 'pair_pattern' } }); | ||||||
const importedNames: string[] = []; | ||||||
for (const s of shorthand) importedNames.push(s.text()); | ||||||
|
AugustinMauroy marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -20,7 +20,7 @@ if (typeof someValue === 'function') { | |||||
if (someValue === null) { | ||||||
console.log('someValue is null'); | ||||||
} | ||||||
if (someValue == null) { | ||||||
if (someValue === null || someValue === undefined) { | ||||||
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. nit:
Suggested change
|
||||||
console.log('someValue is null or undefined'); | ||||||
} | ||||||
if (typeof someValue === 'number') { | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.