Skip to content

geeeger-pkgs/deferred

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

usage

import deferredCreator from "@geeeger/deferred"
import fs from 'fs'
function read(fileName) {
    const deferred = deferredCreator()
    fs.readFile(path, {encoding: 'utf-8'}, (err, data) => {
        if (err) {
            deferred.reject(err)
        }
        else {
            deferred.resolve(data)
        }
    })
    return deferred.promise
}

read()
    .then(() => {
        // balabala
    })
    .catch((e) => {
        // balabala
    })

Releases

No releases published

Packages

No packages published