-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replace lodash by natives js functions
- Loading branch information
1 parent
fb76085
commit 2368996
Showing
43 changed files
with
487 additions
and
521 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
projects/ngx-firestore-repository/src/lib/error/ngx-firestore-repository.error.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { FirestoreRepositoryRequest } from '../public-api'; | ||
|
||
export const get = (obj: unknown, path: string, defValue?: undefined) => { | ||
if (!path) return undefined; | ||
const pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g); | ||
const result = pathArray.reduce( | ||
(prevObj, key) => prevObj && prevObj[key], | ||
obj as any | ||
); | ||
|
||
return result === undefined ? defValue : result; | ||
}; | ||
|
||
|
||
export const omit = (obj: { [x: string]: any; }, props: (string | number)[]) => { | ||
obj = {...obj}; | ||
props.forEach((prop: string | number) => delete obj[prop]); | ||
|
||
return obj; | ||
}; | ||
|
||
export const omitBy = (obj: { [s: string]: unknown; } | ArrayLike<unknown> | FirestoreRepositoryRequest, check: Function) => { | ||
obj = { ...obj }; | ||
Object.entries(obj).forEach(([key, value]) => check(value) && delete obj[key]); | ||
|
||
return obj; | ||
}; | ||
|
||
export const set = (obj: unknown, path: string | string[], value: any) => { | ||
const pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g); | ||
|
||
pathArray.reduce((acc, key, i) => { | ||
if (acc[key] === undefined) acc[key] = {}; | ||
if (i === pathArray.length - 1) acc[key] = value; | ||
|
||
return acc[key]; | ||
}, obj as any); | ||
}; | ||
|
||
export const isString = (a: any): a is string => typeof a === 'string'; | ||
|
||
export const isUndefined = (val: any): val is undefined => val === undefined; | ||
|
||
export const forOwn = <T extends object>(object: T, iteratee: (value: T[keyof T], key: keyof T, object: T) => void): void => { | ||
if (object && typeof object === 'object') { | ||
for (const key in object) { | ||
if (Object.prototype.hasOwnProperty.call(object, key)) { | ||
iteratee(object[key], key, object); | ||
} | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.