-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
32 additions
and
30 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { JsObject } from "./types/JsObject"; | ||
import { JsObject } from './types/JsObject' | ||
|
||
window.jsObject = new JsObject() |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
interface IDownloadOptions { | ||
url: string | ||
fileName?: string | ||
interface IDownloadOptions { | ||
url: string | ||
fileName?: string | ||
} | ||
|
||
export { IDownloadOptions }; | ||
export { IDownloadOptions } |
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 |
---|---|---|
@@ -1,31 +1,31 @@ | ||
class JsObject { | ||
getPropertyList(path: string): string[] { | ||
const res: string[] = path.replace('[', '.').replace(']', '').split('.') | ||
class JsObject { | ||
getPropertyList (path: string): string[] { | ||
const res: string[] = path.replace('[', '.').replace(']', '').split('.') | ||
|
||
if (res[0] === '') { | ||
res.shift() | ||
} | ||
|
||
return res | ||
if (res[0] === '') { | ||
res.shift() | ||
} | ||
|
||
getInstanceProperty(instance: any, propertyPath: string): any { | ||
if (propertyPath === '') { | ||
return instance | ||
} | ||
return res | ||
} | ||
|
||
let currentProperty: any = instance | ||
const splitProperty: string[] = this.getPropertyList(propertyPath) | ||
getInstanceProperty (instance: any, propertyPath: string): any { | ||
if (propertyPath === '') { | ||
return instance | ||
} | ||
|
||
for (let i = 0; i < splitProperty.length; i++) { | ||
if (splitProperty[i] in currentProperty) { | ||
currentProperty = currentProperty[splitProperty[i]] | ||
} else { | ||
return null | ||
} | ||
} | ||
let currentProperty: any = instance | ||
const splitProperty: string[] = this.getPropertyList(propertyPath) | ||
|
||
return currentProperty | ||
for (let i = 0; i < splitProperty.length; i++) { | ||
if (splitProperty[i] in currentProperty) { | ||
currentProperty = currentProperty[splitProperty[i]] | ||
} else { | ||
return null | ||
} | ||
} | ||
|
||
return currentProperty | ||
} | ||
} | ||
export { JsObject } |
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