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
})
-
Notifications
You must be signed in to change notification settings - Fork 0
promise 工具
License
geeeger-pkgs/deferred
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
promise 工具
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published