
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
cli-source-preview
Advanced tools
Preview source code for CLI, useful when display error message with related source.
$ npm install cli-source-preview
'use strict'
const preview = require('cli-source-preview')
const source = `
'use strict'
const chalk = require('chalk')
const PREVIEW_OPTS = {
offset: 5,
lineNumber: true,
delimiter: '\\n'
}
const DELIMITER = '-'.repeat(40)
function rightPad (text, width) {
return text + (width > text.length ? ' '.repeat(width - text.length) : '')
}
`
// preview line 10
console.log(preview(source, 10))
// preview line 5~8
console.log(preview(source, [5, 8]))
// preview line 12:6
console.log(preview(source, { line: 12, column: 6}))
preview (source, line, options)
Get source code parts by line and return with highlighted (CLI) string.
[ Number, Number ]
, the line range to preview{ line: Number, column: Number }
, preivew specified line/columnReturn preview parts string of source
preview.readSource (source, from, to, offset, delimiter)
Read source code by from/to line range.
options.offset
options.delimiter
Return readed source code lines as format:
return [{
number: Number,
source: String
}, ...]
MIT
FAQs
preview source code for CLI
The npm package cli-source-preview receives a total of 20,658 weekly downloads. As such, cli-source-preview popularity was classified as popular.
We found that cli-source-preview 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
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.