-
-
Notifications
You must be signed in to change notification settings - Fork 3
style(eslint): apply specified code style changes #138
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
Changes from 6 commits
54574c8
ebe562d
c33049e
c34389b
607e6c0
24ced7d
3209b2a
ffc58ba
6da9d15
96e08c3
8e963d1
fcb48a3
5dce043
79f5d80
e66a051
5c7205c
74f22dc
d13b925
4545791
1b80afe
a14acd2
881139f
c2f6013
c077e4f
934c84e
b137820
4fc93ee
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 |
|---|---|---|
|
|
@@ -32,11 +32,11 @@ const _hasOwn = Object.prototype.hasOwnProperty; | |
| * @template T | ||
| */ | ||
| export function map<T>(opt_initial: T | undefined) { | ||
| const obj = Object.create(null); | ||
| const object = Object.create(null); | ||
| if (opt_initial) { | ||
| Object.assign(obj, opt_initial); | ||
| Object.assign(object, opt_initial); | ||
| } | ||
| return obj; | ||
| return { ...opt_initial }; | ||
DerekNonGeneric marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /** | ||
|
|
@@ -46,8 +46,8 @@ export function map<T>(opt_initial: T | undefined) { | |
| * @returns {boolean} | ||
| * @template T | ||
| */ | ||
| export function hasOwn<T>(obj: T, key: string) { | ||
| return _hasOwn.call(obj, key); | ||
| export function hasOwn<T>(object: T, key: string) { | ||
DerekNonGeneric marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
DerekNonGeneric marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return _hasOwn.call(object, key); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -57,12 +57,11 @@ export function hasOwn<T>(obj: T, key: string) { | |
| * @param {string} key | ||
| * @returns {unknown} | ||
| */ | ||
| export function ownProperty(obj: Record<string, number | RegExp>, key: string) { | ||
| if (hasOwn(obj, key)) { | ||
| return obj[key]; | ||
| } else { | ||
| return undefined; | ||
| } | ||
| export function ownProperty( | ||
|
||
| object: Record<string, number | RegExp>, | ||
| key: string, | ||
| ) { | ||
DerekNonGeneric marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return hasOwn(object, key) ? object[key] : undefined; | ||
DerekNonGeneric marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| interface ITargetSourceDepth { | ||
|
|
@@ -84,10 +83,10 @@ interface ITargetSourceDepth { | |
| */ | ||
| export function deepMerge(target: Object, source: Object, depth = 10): Object { | ||
DerekNonGeneric marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // Keep track of seen objects to detect recursive references. | ||
| const seen: Array<Object> = []; | ||
| const seen: object[] = []; | ||
|
|
||
| /** @type {!Array<ITargetSourceDepth>} */ | ||
| const queue: Array<ITargetSourceDepth> = []; | ||
| const queue: ITargetSourceDepth[] = []; | ||
| queue.push({ t: target, s: source, d: 0 }); | ||
|
|
||
| // BFS to ensure objects don't have recursive references at shallower depths. | ||
|
|
@@ -104,19 +103,19 @@ export function deepMerge(target: Object, source: Object, depth = 10): Object { | |
| Object.assign(t, s); | ||
| continue; | ||
| } | ||
| Object.keys(s).forEach((key) => { | ||
| for (const key of Object.keys(s)) { | ||
| const newValue = s[key]; | ||
DerekNonGeneric marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // Perform a deep merge IFF both target and source have the same key | ||
| // whose corresponding values are objects. | ||
| if (hasOwn(t, key)) { | ||
| const oldValue = t[key]; | ||
DerekNonGeneric marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (isObject(newValue) && isObject(oldValue)) { | ||
| queue.push({ t: oldValue, s: newValue, d: d + 1 }); | ||
| return; | ||
| continue; | ||
| } | ||
| } | ||
| t[key] = newValue; | ||
DerekNonGeneric marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }); | ||
| } | ||
| } | ||
| return target; | ||
| } | ||
|
|
@@ -130,7 +129,7 @@ export function objectsEqualShallow( | |
| o1: Record<string, number | RegExp> | null | undefined, | ||
| o2: Record<string, number | RegExp> | null | undefined | ||
| ): boolean { | ||
DerekNonGeneric marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (o1 == null || o2 == null) { | ||
| if (o1 == undefined || o2 == undefined) { | ||
| // Null is only equal to null, and undefined to undefined. | ||
| return o1 === o2; | ||
| } | ||
|
|
@@ -160,14 +159,14 @@ export function objectsEqualShallow( | |
| * @template T,R | ||
| */ | ||
| export function memo<T, P extends keyof T>( | ||
|
||
| obj: T, | ||
| prop: P, | ||
| factory: (arg0: T, arg1: P) => T[P] | ||
| object: T, | ||
| property: P, | ||
| factory: (argument0: T, argument1: P) => T[P], | ||
| ): T[P] { | ||
DerekNonGeneric marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| let result = obj[prop]; | ||
| let result = object[property]; | ||
DerekNonGeneric marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (result === undefined) { | ||
| result = factory(obj, prop); | ||
| obj[prop] = result; | ||
| result = factory(object, property); | ||
| object[property] = result; | ||
DerekNonGeneric marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| return result; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.