@socheatsok78/promise-fn
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

promise-fn

A JavaScript/TypeScript alternative way of using Promise.

Install

npm install @socheatsok78/promise-fn
# or
yarn add @socheatsok78/promise-fn

Usage

JavaScript

import { promisefn } from "@socheatsok78/promise-fn"

const agreement = promisefn()

(async () => {
    await agreement.contract
})()

// Resolve or Reject the Promise's agreement

const post = {
    id: 1,
    title: "Hello World"
}

agreement.resolve(post)
// or
agreement.reject()

TypeScript

import { promisefn } from "@socheatsok78/promise-fn"

interface Post {
    id: number
    title: string
}

const agreement = promisefn<Post>()

(async () => {
    const post = await agreement.contract
    console.log(post)
})()

// Resolve or Reject the Promise's agreement

const post: Post = {
    id: 1,
    title: "Hello World"
}

agreement.resolve(post)
// or
agreement.reject()

License

Licensed under Apache-2.0 license

Readme

Keywords

none

Package Sidebar

Install

npm i @socheatsok78/promise-fn

Weekly Downloads

1

Version

1.0.1

License

Apache-2.0

Unpacked Size

26.2 kB

Total Files

10

Last publish

Collaborators

  • andrewalex