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

@bluelovers/fs-json

v1.0.17

Published

Enhanced JSON file operations with final EOL support / 增強型 JSON 檔案操作,支援結尾換行符號

Readme

@bluelovers/fs-json

Enhanced JSON file operations with final EOL (End of Line) support. 增強型 JSON 檔案操作,支援結尾換行符號(EOL)。

Features / 功能

  • Read and write JSON files / 讀寫 JSON 檔案
  • Output JSON with auto directory creation / 輸出 JSON 並自動創建目錄
  • Stringify JSON with final EOL option / 字串化 JSON 並支援結尾換行選項
  • Parse JSON from string or Uint8Array / 從字串或 Uint8Array 解析 JSON
  • Based on fs-extra and jsonfile / 基於 fs-extra 和 jsonfile

Install / 安裝

yarn add @bluelovers/fs-json
yarn-tool add @bluelovers/fs-json
yt add @bluelovers/fs-json
pnpm add @bluelovers/fs-json
npm install @bluelovers/fs-json

Quick Start / 快速開始

import {
  readJSON,
  readJSONSync,
  writeJSON,
  writeJSONSync,
  outputJSON,
  outputJSONSync,
  stringifyJSON,
  parseJSON
} from '@bluelovers/fs-json';

// Read JSON / 讀取 JSON
const data = await readJSON('config.json');
const dataSync = readJSONSync('config.json');

// Write JSON / 寫入 JSON
await writeJSON('output.json', { key: 'value' });
writeJSONSync('output.json', { key: 'value' });

// Output JSON (creates directory if needed) / 輸出 JSON(必要時創建目錄)
await outputJSON('path/to/file.json', { key: 'value' });
outputJSONSync('path/to/file.json', { key: 'value' });

// Stringify with final EOL / 字串化並添加結尾換行
const jsonString = stringifyJSON({ key: 'value' });
console.log(jsonString); // '{"key":"value"}\n'

// Parse JSON / 解析 JSON
const obj = parseJSON('{"key":"value"}');
const objFromUint8 = parseJSON(new Uint8Array([123, 34, 107, 101, 121, 34, 58, 34, 118, 97, 108, 117, 101, 34, 125]));

API

readJSON(file, options?) / readJSONSync(file, options?)

Reads a JSON file asynchronously or synchronously. 異步或同步讀取 JSON 檔案。

writeJSON(file, data, options?) / writeJSONSync(file, data, options?)

Writes a JSON file asynchronously or synchronously. 異步或同步寫入 JSON 檔案。

outputJSON(file, data, options?) / outputJSONSync(file, data, options?)

Writes a JSON file, creating the directory if it doesn't exist. 寫入 JSON 檔案,如果目錄不存在則自動創建。

stringifyJSON(data, options?)

Stringifies data to JSON with final EOL support. 將資料字串化為 JSON,支援結尾換行。

parseJSON(stringOrUint8Array, reviver?)

Parses JSON from string or Uint8Array. 從字串或 Uint8Array 解析 JSON。

Options / 選項

interface IWriteOptions {
  finalEOL?: boolean;  // Add final newline (default: true) / 添加結尾換行(預設:true)
  spaces?: string | number;  // Indentation / 縮排
  // ... other fs-extra/jsonfile options
}