{"id":18034674,"url":"https://github.com/yuanqing/fastmatter","last_synced_at":"2025-10-04T01:31:48.453Z","repository":{"id":19805287,"uuid":"23065363","full_name":"yuanqing/fastmatter","owner":"yuanqing","description":":eyes: A fast frontmatter parser. Supports both string and stream inputs.","archived":false,"fork":false,"pushed_at":"2021-01-30T07:40:01.000Z","size":266,"stargazers_count":28,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-17T23:40:22.920Z","etag":null,"topics":["frontmatter","markdown","nodejs","yaml"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yuanqing.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-18T09:18:57.000Z","updated_at":"2023-10-20T09:37:46.000Z","dependencies_parsed_at":"2022-08-31T20:51:25.336Z","dependency_job_id":null,"html_url":"https://github.com/yuanqing/fastmatter","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuanqing%2Ffastmatter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuanqing%2Ffastmatter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuanqing%2Ffastmatter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuanqing%2Ffastmatter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuanqing","download_url":"https://codeload.github.com/yuanqing/fastmatter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235208983,"owners_count":18953003,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["frontmatter","markdown","nodejs","yaml"],"created_at":"2024-10-30T11:13:20.892Z","updated_at":"2025-10-04T01:31:47.952Z","avatar_url":"https://github.com/yuanqing.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# fastmatter [![npm Version](http://img.shields.io/npm/v/fastmatter.svg?style=flat)](https://www.npmjs.org/package/fastmatter) [![Build Status](https://img.shields.io/travis/yuanqing/fastmatter.svg?branch=master\u0026style=flat)](https://travis-ci.org/yuanqing/fastmatter) [![Coverage Status](https://img.shields.io/coveralls/yuanqing/fastmatter.svg?style=flat)](https://coveralls.io/github/yuanqing/fastmatter)\n\n\u003e A fast frontmatter parser. Supports both string and stream inputs.\n\n## Usage\n\nGiven a document `foo.md` containing YAML frontmatter and content:\n\n```md\n---\ntitle: Hello, World!\ntags: [ foo, bar, baz ]\n---\nLorem ipsum dolor sit amet consectetur adipisicing elit.\n```\n\n\u0026hellip;we can parse this document as a string, via [`fastmatter(string)`](#fastmatterstring):\n\n```js\nconst fastmatter = require('fastmatter')\nconst fs = require('fs')\n\nfs.readFile('foo.md', 'utf8', function (error, data) {\n  if (error) {\n    throw error\n  }\n  console.log(fastmatter(data))\n  /* =\u003e\n   * {\n   *   attributes: {\n   *     title: 'Hello, World!',\n   *     tags: [ 'foo', 'bar', 'baz' ]\n   *   },\n   *   body: 'Lorem ipsum dolor sit amet consectetur adipisicing elit.'\n   * }\n   */\n})\n```\n\n\u0026hellip;or as a stream, via [`fastmatter.stream([callback])`](#fastmatterstreamcallback):\n\n```js\nconst fastmatter = require('fastmatter')\nconst fs = require('fs')\nconst concat = require('concat-stream')\n\nfs.createReadStream('foo.md').pipe(\n  fastmatter.stream(function (attributes) {\n    console.log(attributes)\n    /* =\u003e\n     * {\n     *   title: 'Hello, World!',\n     *   tags: [ 'foo', 'bar', 'baz' ]\n     * }\n     */\n    this.pipe(\n      concat(function (body) {\n        console.log(body.toString())\n        //=\u003e Lorem ipsum dolor sit amet consectetur adipisicing elit.\n      })\n    )\n  })\n)\n```\n\n`callback` is called with the frontmatter `attributes`, while the document `body` is simply passed through the stream. Also note that the `this` context of `callback` is the stream itself; this is useful if we want to change the flow of the stream depending on the parsed `attributes`.\n\n## API\n\n```js\nconst fastmatter = require('fastmatter')\n```\n\n### fastmatter(string)\n\nParses the `string` and returns the parsed frontmatter `attributes` and document `body`.\n\n### fastmatter.stream([callback])\n\nCalls `callback` with the parsed frontmatter `attributes`. The `this` context of `callback` is the stream itself. The document `body` is passed through the stream.\n\n## Installation\n\nInstall via [yarn](https://yarnpkg.com):\n\n```sh\n$ yarn add fastmatter\n```\n\nOr [npm](https://npmjs.com):\n\n```sh\n$ npm install --save fastmatter\n```\n\n## License\n\n[MIT](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuanqing%2Ffastmatter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuanqing%2Ffastmatter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuanqing%2Ffastmatter/lists"}