From 9d2bf6171c8d064b842fbc6c55fe8531861ecbbf Mon Sep 17 00:00:00 2001 From: Daniel Hillmann Date: Fri, 23 Aug 2019 16:07:18 +0200 Subject: [PATCH] revert examples.spec --> index.spec and update types --- index.d.ts | 3 ++- test/{index.spec.js => examples.spec.js} | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) rename test/{index.spec.js => examples.spec.js} (97%) diff --git a/index.d.ts b/index.d.ts index 5da0e76..8e2a8b8 100644 --- a/index.d.ts +++ b/index.d.ts @@ -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; diff --git a/test/index.spec.js b/test/examples.spec.js similarity index 97% rename from test/index.spec.js rename to test/examples.spec.js index e21244f..970b639 100644 --- a/test/index.spec.js +++ b/test/examples.spec.js @@ -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);