Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
enhanced-yaml
Advanced tools
Readme
YAML parser and stringifier that preserves comments and styling
enhanced-yaml
is a YAML parser and stringifier written in TypeScript, built on top of the yaml
library. Operating on top of yaml
's powerful AST, enhanced-yaml
is able to preserve as much information from the original source as possible when stringifying, which means that comments and styling can be preserved with very high accuracy.
preserveOriginalOrdering
option is setUsing Yarn:
yarn add enhanced-yaml
Using npm:
npm install enhanced-yaml
TypeScript type definitions are included out-of-the-box.
import {safeLoad, safeDump} from 'enhanced-yaml';
const data = `
# Above: foo
foo: # Aside: foo
bar: # Aside: bar
- 42 # Aside: 42
# A map
- a: # Aside: a
b # Aside: a's value
# A flow-style sequence
- [
# Above: a
a,
b,
c # Aside: c
]
`;
safeLoad(data);
// {
// foo: {
// bar: ['42', { a: 'b' }, ['a', 'b', 'c']],
// },
// }
safeDump(
{
foo: {
bar: ['42', ['c', 'd', 'a'], { a: 'c' }],
},
},
{},
data,
),
// # Above: foo
// foo: # Aside: foo
// bar: # Aside: bar
// - 42 # Aside: 42
//
// # A flow-style sequence
// - [
// c, # Aside: c
// d,
// # Above: a
// a
// ]
//
// # A map
// - a: # Aside: a
// c # Aside: a's value
//
The public API consists mostly of the load
and dump
functions which use the core
schema by default and their safe counterparts (safeLoad
and safeDump
) which use the failsafe
schema.
The function names were picked to be similar to js-yaml
, which is the most widely used JavaScript YAML parser.
enhanced-yaml
's internals are exported under the internal
namespace, but they shouldn't be considered part of the public API and can be changed at any time.
For more details, please consult the documentation.
Notes:
enhanced-yaml
's public API isn't tied to the yaml
library which is used internally and is only an implementation detail.yaml
's options are currently supported. They will be added gradually after considering how much sense they make in the context of preserving the original source's relevant information.enhanced-yaml
takes a unique approach to preserving the relevant information from the original source: rather than encoding the original information inside the parsed JavaScript value (which can often cause parts of the information to be lost when the value is manipulated in unintended ways), it works by taking the original YAML source as an argument to the dump
function. It then parses it into a document and goes over each YAML node in the updated document and tries to find a matching node in the original document. It then mutates the original node with the minimal relevant updated information, which causes all original references to be preserved, which causes all anchors and aliases to be preserved.
FAQs
YAML parser and stringifier that preserves comments and styling
The npm package enhanced-yaml receives a total of 7 weekly downloads. As such, enhanced-yaml popularity was classified as not popular.
We found that enhanced-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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.