Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

frontmeta

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

frontmeta

Front-matter parser for key:value pairs

  • 2.2.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

FrontMeta

FrontMeta is a minimalist front-matter format that uses key:value pairs rather than YAML. This results in a parser that is optimized for both size and speed.

GitHub Releases NPM Release Bundlephobia MIT License Latest Status Release Status

Features

  • ECMAScript Module
  • CommonJS Bundle Included
  • Typescript Compatible

Installation

npm install frontmeta
import frontmeta from 'frontmeta';

Usage

Parse and stringify FrontMeta

FrontMeta.parse()

FrontMeta.parse(frontmeta) : object

  • contents - a string representing the document contents

Example

frontmeta

---
key1:value1
key2:value2
---
This is the document body.
import FrontMeta from '/path/to/frontmeta/index.js';
const frontmeta = // the document frontmeta
const parsed = FrontMeta.parse(frontmeta)
console.log(parsed);
> {
>   "meta": {
>     "key1": "value1",
>     "key2": "value2"
>   },
>   "body": "This is the document body."
> }

FrontMeta.parse()

FrontMeta.stringify(document) : object

  • document - The frontmeta document object
    • meta - the frontmeta key:value data
    • body - the document body

document

{
  "meta": {
    "key1": "value1",
    "key2": "value2"
  },
  "body": "This is the document body."
}
import FrontMeta from '/path/to/frontmeta/index.js';
const document = // the frontmeta document object
const parsed = FrontMeta.stringify(document)
console.log(parsed);
> ---
> key1:value1
> key2:value2
> ---
> This is the document body.

CommonJS

A .cjs bundle is included for CommonJS compatibility

FrontMeta.parse()

const FrontMeta = require('frontmeta');
const frontmeta = // the document frontmeta
const data = FrontMeta.parse(frontmeta);

FrontMeta.stringify()

const FrontMeta = require('frontmeta');
const document = // the frontmeta document object
const data = FrontMeta.stringify(document);

Typings

Typings are generated from JSDoc using Typescript. They are 100% compatible with VSCode Intellisense and will work seamlessly with Typescript.

Keywords

FAQs

Package last updated on 23 May 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc