diff --git a/.gitignore b/.gitignore index 598f10c..8b81173 100644 --- a/.gitignore +++ b/.gitignore @@ -27,5 +27,4 @@ tmp TODO.md package-lock.json browser -index.cjs.js -index.es.js +dist diff --git a/README.md b/README.md index 8e322b9..5c074ab 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,14 @@ Use [isobject](https://github.com/jonschlinkert/isobject) if you only want to ch ## Usage +with es modules ```js -import isPlainObject from 'is-plain-object'; +import { isPlainObject } from 'is-plain-object'; +``` + +or with commonjs +```js +const { isPlainObject } = require('is-plain-object'); ``` **true** when created by the `Object` constructor, or Object.create(null). diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index fd131f0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -declare function isPlainObject(o: any): boolean; - -export default isPlainObject; diff --git a/is-plain-object.d.ts b/is-plain-object.d.ts new file mode 100644 index 0000000..a359940 --- /dev/null +++ b/is-plain-object.d.ts @@ -0,0 +1 @@ +export function isPlainObject(o: any): boolean; diff --git a/index.js b/is-plain-object.js similarity index 94% rename from index.js rename to is-plain-object.js index c10fbd8..7c1a1d2 100644 --- a/index.js +++ b/is-plain-object.js @@ -9,7 +9,7 @@ function isObject(o) { return Object.prototype.toString.call(o) === '[object Object]'; } -export default function isPlainObject(o) { +export function isPlainObject(o) { var ctor,prot; if (isObject(o) === false) return false; diff --git a/package.json b/package.json index e4923f1..27ce8f2 100644 --- a/package.json +++ b/package.json @@ -16,14 +16,20 @@ "url": "https://github.com/jonschlinkert/is-plain-object/issues" }, "license": "MIT", - "main": "index.cjs.js", - "module": "index.es.js", - "types": "index.d.ts", + "main": "dist/is-plain-object.js", + "module": "dist/is-plain-object.mjs", + "types": "is-plain-object.d.ts", "files": [ - "index.d.ts", - "index.es.js", - "index.cjs.js" + "is-plain-object.d.ts", + "dist" ], + "exports": { + ".": { + "import": "./dist/is-plain-object.mjs", + "require": "./dist/is-plain-object.js" + }, + "./package.json": "./package.json" + }, "engines": { "node": ">=0.10.0" }, diff --git a/rollup.config.js b/rollup.config.js index bd32334..828a738 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,20 +1,18 @@ export default { - input: './index.js', + input: './is-plain-object.js', output: [ { format: 'iife', file: 'browser/is-plain-object.js', - name: 'isPlainObject', - exports: 'default' + name: 'library', }, { format: 'cjs', - file: 'index.cjs.js', - exports: 'default' + file: 'dist/is-plain-object.js', }, { - format: 'es', - file: 'index.es.js' + format: 'esm', + file: 'dist/is-plain-object.mjs' } ] } diff --git a/test/browser.html b/test/browser.html index 9f7f772..b3614de 100644 --- a/test/browser.html +++ b/test/browser.html @@ -12,6 +12,8 @@