Skip to content

Commit

Permalink
revert examples.spec --> index.spec and update types
Browse files Browse the repository at this point in the history
  • Loading branch information
hilleer committed Aug 23, 2019
1 parent 11c27ea commit 9d2bf61
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

function set(obj: any, prop: number | string, value: any): any;
function get(obj: any, prop: number | string, value?: any): any;
function get(obj: any, prop: string | string[] | number, value?: any): any;
function toggle(obj: any, prop: number | string): any;
function merge(obj: any, prop: number | string, val: any): any;
function _delete(obj: any, prop: number | string): any;
Expand Down
4 changes: 4 additions & 0 deletions test/index.spec.js → test/examples.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ describe('examples.spec.js', () => {
expect(dotProp.get([{ bar: 'gold-unicorn' }, 'white-unicorn', 'silver-unicorn'], '0.bar')).to.eql('gold-unicorn');
});

it('prop as number', () => {
expect(dotProp.get([{ foo: 'silver-unicorn' }], 0)).to.eql({ foo: 'silver-unicorn' });
});

it('index $end', () => {
expect(dotProp.get({ foo: [{ bar: 'gold-unicorn' }, 'white-unicorn', 'silver-unicorn'] }, 'foo.$end')).to.eql('silver-unicorn');
expect(dotProp.get({ foo: [] }, 'foo.$end')).to.eql(undefined);
Expand Down

0 comments on commit 9d2bf61

Please sign in to comment.