npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

js-yaml-patched

v4.1.0-patched.2

Published

YAML 1.2 parser and serializer with float format preservation patch

Readme

js-yaml-patched

基于 js-yaml 的补丁版本,增加了浮点数格式保留功能。

为什么需要这个补丁?

原始的 js-yaml 在处理浮点数时会丢失原始格式信息。例如:

  • 输入 1.0 会输出 1
  • 输入 2.00 会输出 2

这个补丁版本能够保留原始的浮点数格式,特别适用于需要保持 YAML 文件格式一致性的场景(如 ROS 参数文件、配置文件等)。

安装

npm install js-yaml-patched

使用方法

基本使用

const yaml = require('js-yaml-patched');

// 解析 YAML
const data = yaml.load(`
timeout: 1.0
precision: 2.00
scale_factor: -1.0
`);

// 输出 YAML(格式保留)
const output = yaml.dump(data);
console.log(output);
// 输出:
// timeout: 1.0
// precision: 2.00
// scale_factor: -1.0

ES6 模块

import yaml from 'js-yaml-patched';

const data = yaml.load('value: 5.0');
const output = yaml.dump(data);

补丁说明

本补丁修改了以下文件:

  • lib/type/float.js - 添加浮点数格式保留逻辑
  • lib/type/int.js - 防止格式保留的浮点数被误判为整数

支持的格式

  • 1.0 → 保留为 1.0
  • 2.00 → 保留为 2.00
  • -1.0 → 保留为 -1.0
  • +3.0 → 保留为 3.0+ 号会被移除)

API

与原始 js-yaml 的 API 完全相同:

  • yaml.load(str) - 解析 YAML 字符串
  • yaml.dump(obj) - 将对象转换为 YAML 字符串
  • yaml.safeLoad(str) - 安全解析(已废弃,使用 load
  • yaml.safeDump(obj) - 安全输出(已废弃,使用 dump

版本

License

MIT (与原项目相同)