Skip to content

Commit

Permalink
Add esm exports and improve docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
octet-stream committed Feb 7, 2020
1 parent cb85a54 commit 6183eaf
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.{js,json,md,yml}]
charset = utf-8
indent_style = space
indent_size = 2
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "use-suspender",
"version": "0.1.0",
"description": "Execute asynchronous actions with React.Suspense",
"main": "use-suspense.js",
"main": "use-suspender",
"repository": "[email protected]:octet-stream/use-suspender.git",
"author": "octet-stream <[email protected]>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ to await and consume its result with React.Suspense.
- **{any}** id – an unique identifier for useSuspender.
This value must be consistent between render function calls.

### `createSuspender() -> {Function}`
### `createUseSuspender() -> {Function}`

Creates a new useSuspender function with separated cache.

Expand Down
6 changes: 3 additions & 3 deletions use-suspender.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const isFunction = value => typeof value === "function"

const replacer = (key, value) => String(value)

function createSuspender() {
function createUseSuspender() {
const cache = new Map()
const base = nanoid()

Expand Down Expand Up @@ -98,7 +98,7 @@ function createSuspender() {
return useSuspender
}

module.exports = createSuspender()
module.exports = createUseSuspender()
module.exports.default = module.exports
module.exports.useSuspender = module.exports
module.exports.createSuspender = createSuspender
module.exports.createUseSuspender = createUseSuspender
5 changes: 5 additions & 0 deletions use-suspender.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import useSuspender from "./use-suspender.js"

const {createUseSuspender} = useSuspender

export {useSuspender as default, useSuspender, createUseSuspender}

0 comments on commit 6183eaf

Please sign in to comment.