
Security News
rv Is a New Rust-Powered Ruby Version Manager Inspired by Python's uv
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
fs-extra has a promise-based API as of v4.0.0. TypeScript-friendly.
fs-p
is a TypeScript-friendly promise-based wrapper on top of fs-extra package.
Previously, there was no TypeScript-friendly promise-based fs-extra
implementation. Now there is.
npm install --save fs-p
or yarn add fs-p
fs-p
api is no different from fs-extra
, except, async methods are wrapped in Promises.
Check out the original fs-extra
documentation.
Most methods are async and return Promises, unlike the original fs-extra
callback-based implementaion.
Sync methods, on the other hand, will throw if an error occurs.
fs-p
vs fs-extra
Methods with no return value example:
import * as fs from 'fs-extra'
import * as fsp from 'fs-p'
// fs-extra callback style
fs.copy('/tmp/myfile', '/tmp/mynewfile', (err: Error) => {
if (err) return console.error(err)
console.log("success!")
}) // copies file
// fs-p promise-based
fsp.copy('/tmp/mydir', '/tmp/mynewdir').then(
() => console.log('success!')
).catch((err) => console.error(err))
// fs-p async/await
try {
await fsp.copy('/tmp/mydir', '/tmp/mynewdir')
console.log('success!')
} catch (err) { console.error(err) }
Methods with a return value:
import * as fs from 'fs-extra'
import * as fsp from 'fs-p'
// fs-extra callback style
fs.readJson('./package.json', (err: Error, packageObj: any) => {
console.log(packageObj.version) // => 0.1.3
})
// fs-p promise-based
fsp.readJson('./package.json').then(
(packageObj: any) => console.log(packageObj.version) // => 0.1.3
).catch((err) => console.error(err))
// fs-p async/await
try {
const packageObj: any = await fsp.readJson('./package.json')
console.log(packageObj.version) // => 0.1.3
} catch (err) { console.error(err) }
fs-p
is just a small wrapper over a remarkable fs-extra
package. Thus, all the credit goes to fs-extra
authors
Copyright 2017 Grammarly, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
FAQs
fs-extra on Promises. Typescript-friendly
The npm package fs-p receives a total of 70 weekly downloads. As such, fs-p popularity was classified as not popular.
We found that fs-p demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.