Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
mapped-yaml
Advanced tools
A simple yaml parser providing source map as well.
npm i mapped-yaml
import { readFile } from 'fs/promises'
import { parse } from 'mapped-yaml'
async main() {
const content = await readFile('./stuff.yml', 'utf8')
const parsed = parse(content, './stuff.yml')
// 👉 access parsed contents of each node using `.object` property
assert(parsed.object['hellow'].object === 'world')
assert(parsed.object['stuff'].object[0].object === 42)
assert(parsed.object['stuff'].object[1].object['foo'].object === 'bar')
// 👉 access location of each node using `.location` property
console.log(parsed.object['stuff'].object[1].location)
// {
// file: File { ... },
// range: {
// start: { line: 4, character: 4 },
// end: { line: 4, character: 11 }
// }
// }
// 👉 get the contents of the file maybe with some surrounding lines even
console.log(
parsed.location.file.range( // --> returns the contents of the file for given range
parsed.object['stuff'].object[0].location.range, // --> the range of '- 42'
{ surrounding: 1 } // --> also return 1 surrounding line.
)
)
// {
// 2: { content: 'stuff:', surround: true },
// 3: { content: ' - 42', surround: false },
// 4: { content: ' - foo: bar', surround: true }
// }
}
# stuff.yml
hellow: world
stuff:
- 42
- foo: bar
⚠️ Line and character indexes are ZERO-BASED. ⚠️
This is a simple wrapper over yaml. If you don't need source mapping, most probably you should just use that package.
FAQs
A simple yaml parser providing source map
The npm package mapped-yaml receives a total of 118 weekly downloads. As such, mapped-yaml popularity was classified as not popular.
We found that mapped-yaml 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
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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.