Skip to content

Commit

Permalink
Require Node.js 12 and move to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 16, 2021
1 parent 2bfe260 commit 69581e4
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 17 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Expand Up @@ -12,10 +12,9 @@ jobs:
node-version:
- 14
- 12
- 10
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
6 changes: 2 additions & 4 deletions index.d.ts
Expand Up @@ -5,7 +5,7 @@ An object is plain if it's created by either `{}`, `new Object()`, or `Object.cr
@example
```
import isPlainObject = require('is-plain-obj');
import isPlainObject from 'is-plain-obj';
isPlainObject({foo: 'bar'});
//=> true
Expand All @@ -24,6 +24,4 @@ isPlainObject(new Unicorn());
//=> false
```
*/
declare function isPlainObject<Value = unknown>(value: unknown): value is Record<string | number | symbol, Value>;

export = isPlainObject;
export default function isPlainObject<Value>(value: unknown): value is Record<string | number | symbol, Value>;
6 changes: 2 additions & 4 deletions index.js
@@ -1,10 +1,8 @@
'use strict';

module.exports = value => {
export default function isPlainObject(value) {
if (Object.prototype.toString.call(value) !== '[object Object]') {
return false;
}

const prototype = Object.getPrototypeOf(value);
return prototype === null || prototype === Object.prototype;
};
}
2 changes: 1 addition & 1 deletion index.test-d.ts
@@ -1,5 +1,5 @@
import {expectAssignable} from 'tsd';
import isPlainObject = require('.');
import isPlainObject from './index.js';

const foo = 'foo';

Expand Down
10 changes: 6 additions & 4 deletions package.json
Expand Up @@ -10,8 +10,10 @@
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=10"
"node": ">=12"
},
"scripts": {
"test": "xo && ava && tsd"
Expand All @@ -32,8 +34,8 @@
"simple"
],
"devDependencies": {
"ava": "^2.4.0",
"tsd": "^0.13.1",
"xo": "^0.33.1"
"ava": "^3.15.0",
"tsd": "^0.14.0",
"xo": "^0.38.2"
}
}
2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -13,7 +13,7 @@ $ npm install is-plain-obj
## Usage

```js
const isPlainObject = require('is-plain-obj');
import isPlainObject from 'is-plain-obj';

isPlainObject({foo: 'bar'});
//=> true
Expand Down
2 changes: 1 addition & 1 deletion test.js
@@ -1,5 +1,5 @@
import test from 'ava';
import isPlainObject from '.';
import isPlainObject from './index.js';

function Foo(x) {
this.x = x;
Expand Down

0 comments on commit 69581e4

Please sign in to comment.