Skip to content

Commit

Permalink
feat: basic get
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Nov 7, 2018
1 parent c6478c7 commit 71e2229
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 11 additions & 0 deletions src/get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import forOwn from './forOwn'
import toPath from './toPath'

export default function get(value: object, path: string | string[], defaultValue?: any): any {
path = Array.isArray(path) ? path : toPath(path)
const result: any = defaultValue
const last: any = value
for (let i = 0, len = path.length; i < len; i++) {

}
}
6 changes: 0 additions & 6 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1214,11 +1214,5 @@ describe('request', () => {
})
expect(data.status).toBe(200)
expect(data.data.id).toBe(1)
const data2: any = await vtils.request({
url: 'https://jsonplaceholder.typicode.com/todos/1',
method: 'POST'
})
expect(data2.status).toBe(200)
expect(data2.data.id).toBe(1)
})
})

0 comments on commit 71e2229

Please sign in to comment.