Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Promise-based write for Node.js
wrote(filepath?:String) => Promise<Writable> (ws.writable == true)
Create a write stream to your file without hastle.
const Writable = require('stream').Writable
const path = require('path')
const wrote = require('./')
const HOME_DIR = require('os').homedir()
const file = path.join(HOME_DIR, `wrote-${Math.floor(Math.random() * 1e5)}.data`)
return wrote(file)
.then((ws) => {
console.log(ws instanceof Writable) // true
console.log(ws.path) // ~/wrote-35558.data
})
.catch(console.error)
If you don't have a file, a new one in the temp directory will be created for you.
const wrote = require('wrote')
const Writable = require('stream').Writable
return wrote()
.then((ws) => {
console.log(ws instanceof Writable) // true
console.log(ws.path) // /var/folders/s0/l33t/T/wrote-35558.data
})
.catch(console.error)
wrote.erase(ws:Writable) => Promise<Writable> (ws.writable == false)
Erase file and close stream.
const wrote = require('wrote')
const Writable = require('stream').Writable
const path = require('path')
const HOME_DIR = require('os').homedir()
const fs = require('fs')
const file = path.join(HOME_DIR, `wrote-${Math.floor(Math.random() * 1e5)}.data`)
return wrote(file)
.then((ws) => {
console.log(ws instanceof Writable) // true
console.log(ws.writable) // true
console.log(ws.path) // ~/wrote-35558.data
return wrote.erase(ws)
})
.then((ws) => {
console.log(ws.path) // ~/wrote-35558.data, but no longer exists
console.log(ws.writable) // false
})
.catch(console.error)
Pipe a Readable
to the Writable
stream and wait until it is finished, or end Writable
with
given data (pass null
to end stream without any more data).
const wrote = require('wrote')
const assert = require('assert')
const Writable = require('stream').Writable
const testString = 'hello world'
const buffer = Buffer.from(testString)
const allRawData = []
const ws = new Writable({
write: (chunk, encoding, next) => {
allRawData.push(chunk)
next()
},
})
wrote.write(ws, buffer)
.then(() => {
console.log(allRawData.map(d => String(d))) // [ 'hello world' ]
assert.deepEqual(allRawData, [
buffer,
])
})
.catch(console.error)
fs.createWriteStream
Licence: MIT
(c) Sobesednik-Media 2017
0.3.0 (28 May 2017)
wrote.write
: write to the stream and return a promise resolved when the stream
finishes.FAQs
Promise-based writing to filesystem for Node.js
The npm package wrote receives a total of 2,364 weekly downloads. As such, wrote popularity was classified as popular.
We found that wrote 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.