Skip to content

segurvita/yaml-scraper

Repository files navigation

yaml-scraper Build Status

Language: English | 日本語

Delete or empty specified items to lighten your YAML document.

Purpose

The purpose of this module is to avoid capacity limit errors that occur when importing a swagger file into Amazon API Gateway.

Usage

This module require npm. If npm has already been installed, you can install the library with the following command.

npm install yaml-scraper

Please call the module as following.

// import package
const fs = require('fs');
const scraper = require('yaml-scraper');

// read yaml file
const input = fs.readFileSync('./sample.yaml', 'utf8');

// delete example and empty description and delete parent of deprecated
const output = scraper(input)
  .delete('example')
  .empty('description')
  .deleteParent('deprecated')
  .toString();

// display result
console.log(output);

API

scraper(input)

Parses input as YAML format. Please call this function first, and then connect method chains below.

delete(target)

Delete the item whose key is target. It can be used for method chain.

empty(target)

Replace the value of target with '' . It can be used for method chain.

deleteParent(target)

Delete the element whose child has target. It can be used for method chain.

toString()

Generate a YAML format string based on the current data and return it.

Development

If you edit this project, you can clone it from the repository and build the development environment with the following command.

# Install required packages
npm install

# Run the test
npm test

About

Delete or empry item of your YAML document. YAMLファイルを軽量化します。

Resources

License

Stars

Watchers

Forks

Packages

No packages published