@targetd/fs
TypeScript icon, indicating that this package has built-in type declarations

5.0.0 • Public • Published

@targetd/fs

Load rules from JSON and YAML files

Example

/* rules/foo.json */
{
  "foo": [
    {
      "payload": "bar"
    }
  ]
}
# rules/d.yaml
b:
  - payload: b is a letter
import { Data } from '@targetd/api'
import { watch } from '@targetd/fs'
import * as path from 'node:path'
import z from 'zod'

watch(
  Data.create({
    data: {
      foo: z.string(),
      b: z.string(),
    },
  }),

  path.join(__dirname, 'rules'),

  async (data) => {
    expect(await data.getPayload('foo', {})).toBe('bar')
    expect(await data.getPayload('b', {})).toBe('b is a letter')
  },
)

Readme

Keywords

none

Package Sidebar

Install

npm i @targetd/fs

Weekly Downloads

3

Version

5.0.0

License

MIT

Unpacked Size

16 kB

Total Files

25

Last publish

Collaborators

  • johngeorgewright