Skip to content

Commit 3b67964

Browse files
committedMay 9, 2024
Require Node.js 18
Closes #115
1 parent 3dd188c commit 3b67964

File tree

8 files changed

+91
-67
lines changed

8 files changed

+91
-67
lines changed
 

Diff for: ‎.github/funding.yml

-4
This file was deleted.

Diff for: ‎.github/workflows/main.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ jobs:
1212
node-version:
1313
- 20
1414
- 18
15-
- 16
1615
steps:
17-
- uses: actions/checkout@v3
18-
- uses: actions/setup-node@v3
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-node@v4
1918
with:
2019
node-version: ${{ matrix.node-version }}
2120
- run: npm install

Diff for: ‎benchmark.js

+24-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import Benchmark from 'benchmark';
2-
import {getProperty, setProperty, hasProperty, deleteProperty} from './index.js';
2+
import {
3+
getProperty,
4+
setProperty,
5+
hasProperty,
6+
deleteProperty,
7+
} from './index.js';
38

49
const suite = new Benchmark.Suite();
510

@@ -34,11 +39,11 @@ suite
3439
getProperty(fixture2, 'foo');
3540
getProperty({}, 'hasOwnProperty');
3641

37-
function fn() {}
38-
fn.foo = {bar: 1};
39-
getProperty(fn);
40-
getProperty(fn, 'foo');
41-
getProperty(fn, 'foo.bar');
42+
function function_() {}
43+
function_.foo = {bar: 1};
44+
getProperty(function_);
45+
getProperty(function_, 'foo');
46+
getProperty(function_, 'foo.bar');
4247

4348
const fixture3 = {foo: null};
4449
getProperty(fixture3, 'foo.bar');
@@ -52,7 +57,7 @@ suite
5257
getProperty(undefined, 'foo.bar', false);
5358
})
5459
.add('setProperty', () => {
55-
const func = () => 'test';
60+
const function_ = () => 'test';
5661
let fixture1 = {};
5762

5863
setProperty(fixture1, 'foo', 2);
@@ -72,12 +77,12 @@ suite
7277

7378
setProperty(fixture1, 'foo.fake.fake2', 'fake');
7479

75-
setProperty(fixture1, 'foo.function', func);
80+
setProperty(fixture1, 'foo.function', function_);
7681

77-
function fn() {}
78-
setProperty(fn, 'foo.bar', 1);
82+
function function__() {}
83+
setProperty(function__, 'foo.bar', 1);
7984

80-
fixture1.fn = fn;
85+
fixture1.fn = function__;
8186
setProperty(fixture1, 'fn.bar.baz', 2);
8287

8388
const fixture2 = {foo: null};
@@ -102,24 +107,24 @@ suite
102107
hasProperty({foo: {bar: {baz: null}}}, 'foo.bar.baz');
103108
hasProperty({foo: {bar: 'a'}}, 'foo.fake.fake2');
104109

105-
function fn() {}
106-
fn.foo = {bar: 1};
107-
hasProperty(fn);
108-
hasProperty(fn, 'foo');
109-
hasProperty(fn, 'foo.bar');
110+
function function_() {}
111+
function_.foo = {bar: 1};
112+
hasProperty(function_);
113+
hasProperty(function_, 'foo');
114+
hasProperty(function_, 'foo.bar');
110115

111116
hasProperty({'foo.baz': {bar: true}}, 'foo\\.baz.bar');
112117
hasProperty({'fo.ob.az': {bar: true}}, 'fo\\.ob\\.az.bar');
113118
})
114119
.add('deleteProperty', () => {
115-
const func = () => 'test';
116-
func.foo = 'bar';
120+
const function_ = () => 'test';
121+
function_.foo = 'bar';
117122

118123
const inner = {
119124
a: 'a',
120125
b: 'b',
121126
c: 'c',
122-
func,
127+
func: function_,
123128
};
124129

125130
const fixture1 = {

Diff for: ‎index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ export function escapePath(path) {
290290
throw new TypeError('Expected a string');
291291
}
292292

293-
return path.replace(/[\\.[]/g, '\\$&');
293+
return path.replaceAll(/[\\.[]/g, '\\$&');
294294
}
295295

296296
// The keys returned by Object.entries() for arrays are strings

Diff for: ‎index.test-d.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import {expectTypeOf} from 'expect-type';
2-
import {getProperty, setProperty, hasProperty, deleteProperty, escapePath, deepKeys} from './index.js';
2+
import {
3+
getProperty,
4+
setProperty,
5+
hasProperty,
6+
deleteProperty,
7+
escapePath,
8+
deepKeys,
9+
} from './index.js';
310

411
expectTypeOf(getProperty({foo: {bar: 'unicorn'}}, 'foo.bar')).toBeString();
512
expectTypeOf(getProperty({foo: {bar: 'a'}}, 'foo.notDefined.deep')).toBeUndefined();

Diff for: ‎package.json

+11-7
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@
1111
"url": "https://sindresorhus.com"
1212
},
1313
"type": "module",
14-
"exports": "./index.js",
14+
"exports": {
15+
"types": "./index.d.ts",
16+
"default": "./index.js"
17+
},
18+
"sideEffects": false,
1519
"engines": {
16-
"node": ">=16"
20+
"node": ">=18"
1721
},
1822
"scripts": {
1923
"test": "xo && ava && tsc",
@@ -37,13 +41,13 @@
3741
"dotty"
3842
],
3943
"dependencies": {
40-
"type-fest": "^3.8.0"
44+
"type-fest": "^4.18.2"
4145
},
4246
"devDependencies": {
43-
"ava": "^5.2.0",
47+
"ava": "^6.1.3",
4448
"benchmark": "^2.1.4",
45-
"expect-type": "^0.15.0",
46-
"typescript": "^5.0.4",
47-
"xo": "^0.54.1"
49+
"expect-type": "^0.19.0",
50+
"typescript": "^5.4.5",
51+
"xo": "^0.58.0"
4852
}
4953
}

Diff for: ‎test.js

+44-31
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import test from 'ava';
2-
import {getProperty, setProperty, hasProperty, deleteProperty, escapePath, deepKeys} from './index.js';
2+
import {
3+
getProperty,
4+
setProperty,
5+
hasProperty,
6+
deleteProperty,
7+
escapePath,
8+
deepKeys,
9+
} from './index.js';
310

411
test('getProperty', t => {
512
const fixture1 = {foo: {bar: 1}};
@@ -25,9 +32,11 @@ test('getProperty', t => {
2532
t.true(getProperty({'foo\\bar': true}, 'foo\\bar'));
2633
t.true(getProperty({'\\': {foo: true}}, '\\\\.foo'));
2734
t.true(getProperty({'bar\\.': true}, 'bar\\\\\\.'));
28-
t.true(getProperty({'foo\\': {
29-
bar: true,
30-
}}, 'foo\\\\.bar'));
35+
t.true(getProperty({
36+
'foo\\': {
37+
bar: true,
38+
},
39+
}, 'foo\\\\.bar'));
3140
t.is(getProperty({foo: 1}, 'foo.bar'), undefined);
3241
t.true(getProperty({'foo\\': true}, 'foo\\'));
3342

@@ -39,11 +48,11 @@ test('getProperty', t => {
3948
t.is(getProperty(fixture2, 'foo'), 'bar');
4049
t.is(getProperty({}, 'hasOwnProperty'), Object.prototype.hasOwnProperty);
4150

42-
function fn() {}
43-
fn.foo = {bar: 1};
44-
t.is(getProperty(fn), fn);
45-
t.is(getProperty(fn, 'foo'), fn.foo);
46-
t.is(getProperty(fn, 'foo.bar'), 1);
51+
function function_() {}
52+
function_.foo = {bar: 1};
53+
t.is(getProperty(function_), function_);
54+
t.is(getProperty(function_, 'foo'), function_.foo);
55+
t.is(getProperty(function_, 'foo.bar'), 1);
4756

4857
const f3 = {foo: null};
4958
t.is(getProperty(f3, 'foo.bar'), undefined);
@@ -135,9 +144,11 @@ test('getProperty - with array indexes', t => {
135144
t.false(getProperty([true], '0', false));
136145

137146
t.false(getProperty({foo: [true]}, 'foo.0', false));
138-
t.true(getProperty({foo: {
139-
0: true,
140-
}}, 'foo.0'));
147+
t.true(getProperty({
148+
foo: {
149+
0: true,
150+
},
151+
}, 'foo.0'));
141152

142153
t.true(getProperty([{
143154
'[1]': true,
@@ -161,7 +172,7 @@ test('getProperty - with array indexes', t => {
161172
});
162173

163174
test('setProperty', t => {
164-
const func = () => 'test';
175+
const function_ = () => 'test';
165176
let fixture1 = {};
166177

167178
const o1 = setProperty(fixture1, 'foo', 2);
@@ -190,14 +201,14 @@ test('setProperty', t => {
190201
setProperty(fixture1, 'foo.fake.fake2', 'fake');
191202
t.is(fixture1.foo.fake.fake2, 'fake');
192203

193-
setProperty(fixture1, 'foo.function', func);
194-
t.is(fixture1.foo.function, func);
204+
setProperty(fixture1, 'foo.function', function_);
205+
t.is(fixture1.foo.function, function_);
195206

196-
function fn() {}
197-
setProperty(fn, 'foo.bar', 1);
198-
t.is(fn.foo.bar, 1);
207+
function function__() {}
208+
setProperty(function__, 'foo.bar', 1);
209+
t.is(function__.foo.bar, 1);
199210

200-
fixture1.fn = fn;
211+
fixture1.fn = function__;
201212
setProperty(fixture1, 'fn.bar.baz', 2);
202213
t.is(fixture1.fn.bar.baz, 2);
203214

@@ -253,14 +264,14 @@ test('setProperty', t => {
253264
});
254265

255266
test('deleteProperty', t => {
256-
const func = () => 'test';
257-
func.foo = 'bar';
267+
const function_ = () => 'test';
268+
function_.foo = 'bar';
258269

259270
const inner = {
260271
a: 'a',
261272
b: 'b',
262273
c: 'c',
263-
func,
274+
func: function_,
264275
};
265276
const fixture1 = {
266277
foo: {
@@ -285,7 +296,7 @@ test('deleteProperty', t => {
285296
t.true(deleteProperty(fixture1, 'foo.bar.baz.func.foo'));
286297
t.is(fixture1.foo.bar.baz.func.foo, undefined);
287298

288-
t.is(fixture1.foo.bar.baz.func, func);
299+
t.is(fixture1.foo.bar.baz.func, function_);
289300
t.true(deleteProperty(fixture1, 'foo.bar.baz.func'));
290301
t.is(fixture1.foo.bar.baz.func, undefined);
291302

@@ -362,11 +373,11 @@ test('hasProperty', t => {
362373
t.false(hasProperty({foo: null}, 'foo.bar'));
363374
t.false(hasProperty({foo: ''}, 'foo.bar'));
364375

365-
function fn() {}
366-
fn.foo = {bar: 1};
367-
t.false(hasProperty(fn));
368-
t.true(hasProperty(fn, 'foo'));
369-
t.true(hasProperty(fn, 'foo.bar'));
376+
function function_() {}
377+
function_.foo = {bar: 1};
378+
t.false(hasProperty(function_));
379+
t.true(hasProperty(function_, 'foo'));
380+
t.true(hasProperty(function_, 'foo.bar'));
370381

371382
t.true(hasProperty({'foo.baz': {bar: true}}, 'foo\\.baz.bar'));
372383
t.true(hasProperty({'fo.ob.az': {bar: true}}, 'fo\\.ob\\.az.bar'));
@@ -382,9 +393,11 @@ test('hasProperty', t => {
382393
foo: [{bar: ['bar', 'bizz']}],
383394
}, 'foo[1].bar.1'));
384395
t.true(hasProperty({
385-
foo: [{bar: {
386-
1: 'bar',
387-
}}],
396+
foo: [{
397+
bar: {
398+
1: 'bar',
399+
},
400+
}],
388401
}, 'foo[0].bar.1'));
389402
});
390403

Diff for: ‎tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"compilerOptions": {
33
"lib": [
4-
"es2021"
4+
"es2022"
55
],
66
"strict": true,
77
"noEmit": true

0 commit comments

Comments
 (0)
Please sign in to comment.