node core libs with promises and better errors
Currently just fs
is supported.
npm install --save newcore
Example:
var fs = require('newcore/lib/fs');
fs.readFile('lorem.txt', 'utf-8')
.then((text) => {
console.log(text);
})
// selective error handling
.catch(fs.errors.NotFound, () => {
console.log('File lorem.txt is missing');
});
Errors:
Code | Error Name |
---|---|
EACCES | fs.errros.PermissionDenied |
EEXIST | fs.errors.FileExists |
EISDIR | fs.errors.IsDirectory |
ENOTDIR | fs.errors.NotDirectory |
ENOTEMPTY | fs.errors.NotEmptyDirectory |
ENOENT | fs.errors.NotFound |
EMFILE | fs.errors.OutOfFileDescriptors |
EPERM | fs.errors.Permissions |
Add all of the apis mentioned here nodejs/node#5020