
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.