
Product
Introducing Supply Chain Attack Campaigns Tracking in the Socket Dashboard
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.
snippet-stream
Advanced tools
Split a stream of JS source code into parsable snippets
npm install snippet-stream
Uses snippetify for all the heavy lifting
var snippets = require('snippet-stream')
// create a snippet stream
var stream = snippets()
// write some js to it
stream.write('var a = 1\n')
stream.write('function foo () {\n')
stream.write(' return a + 1\n')
stream.write('}\n')
stream.write('foo()')
stream.end()
stream.on('data', function (data) {
console.log('snippet:')
console.log(data)
})
Running the above produces the following output
snippet:
var a = 1
snippet:
function foo () {
return a + 1
}
snippet:
foo()
You can use this to create a streaming eval function
var snippets = require('snippet-stream')
// create a snippet stream
var stream = snippets()
var scope = {}
// write some js to it
stream.write('var a = 1\n')
stream.write('function foo () {\n')
stream.write(' return a + 1\n')
stream.write('}\n')
stream.write('console.log(foo())')
stream.end()
stream.on('data', function (data) {
eval.call(scope, data)
})
MIT
FAQs
Split a stream of JS source code into parsable snippets
We found that snippet-stream 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.

Product
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.

Research
Malicious PyPI package sympy-dev targets SymPy users, a Python symbolic math library with 85 million monthly downloads.

Security News
Node.js 25.4.0 makes require(esm) stable, formalizing CommonJS and ESM compatibility across supported Node versions.