From 95692cf5540f1c0777ec08464ad5cc2a420406d6 Mon Sep 17 00:00:00 2001 From: Asko Nõmm Date: Tue, 28 Jan 2025 21:29:22 +0200 Subject: Improve docs, namings --- README.md | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 1522392..787736a 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,6 @@ Additionally, FlatMatter also parses FrontMatter content, meaning that a FlatMat --- title: "Hello, World!" --- - Content goes here. ``` @@ -34,8 +33,8 @@ Would result in this data being created: ```json { - "title": "Hello, World!", - "content": "Content goes here." + "title": "Hello, World!", + "content": "Content goes here." } ``` @@ -50,10 +49,10 @@ npm i flatmatter The most basic usage looks like this: ```typescript -import {FlatMatter, ToObject} from 'flatmatter'; +import { FlatMatter, ToObject } from "flatmatter"; const fm = new FlatMatter('key: "value"'); -const config = fm.serialize(new ToObject); +const config = fm.serialize(new ToObject()); // {key: "value"} ``` @@ -63,7 +62,7 @@ However, you most likely want to use it with functions. Those you have to create **TypeScript:** ```typescript -import {FlatMatterFn} from "flatmatter"; +import { FlatMatterFn } from "flatmatter"; class ToUpper implements FlatMatterFn { name = "to-upper"; @@ -92,7 +91,7 @@ mind is that if the function is piped, the first argument passed to it will be t Once you have your functions, simply pass them to FlatMatter like this: ```typescript -import {FlatMatter, ToObject} from 'flatmatter'; +import { FlatMatter, ToObject } from "flatmatter"; const fm = new FlatMatter('key: "value" / to-upper', [new MyFunction()]); const config = fm.serialize(new ToObject()); @@ -111,11 +110,11 @@ creating a class that implements the `Serializer` interface. **TypeScript:** ```typescript -import {Matter, Serializer} from 'flatmatter'; +import { Serializer } from "flatmatter"; class ToJson implements Serializer { - serialize(parsedConfig: Matter): string { - return JSON.stringify(parsedConfig); + serialize(config: Record): string { + return JSON.stringify(config); } } ``` @@ -124,10 +123,10 @@ class ToJson implements Serializer { ```javascript class ToJson { - serialize(parsedConfig) { - return JSON.stringify(parsedConfig); + serialize(config) { + return JSON.stringify(config); } } ``` -**Note:** if you don't like classes, you can also pass objects that have the `serialize` callback function. \ No newline at end of file +**Note:** if you don't like classes, you can also pass objects that have the `serialize` callback function. -- cgit v1.2.3