Numerous Pancakes Munched

    @hidoo/data-from

    0.3.1 • Public • Published

    @hidoo/data-from

    Status

    A utility library that get data from JSON, JSON5, and YAML.

    Installation

    $ npm install @hidoo/data-from

    Usage

    from string:

    import {fromString} from '@hidoo/data-from';
    
    const data = fromString('{"test": {"hoge": "hoge", "fuga": "{{test.hoge}}');
    // {test: {hoge: 'hoge', fuga: 'hoge'}}

    from Front Matter (wrapper of front-matter):

    import {fromFrontMatter} from '@hidoo/data-from';
    
    const data = fromFrontMatter('---\ntest:\n  hoge: hoge\n  fuga: "{{test.hoge}}"\n---\n');
    // {body: '', attributes: {test: {hoge: 'hoge', fuga: 'hoge'}}, frontmatter: 'test:\n  hoge: hoge\n  fuga: "{{test.hoge}}"'}

    from files (glob pattern):

    // data.json5
    {
      data: {
        hoge: 'hoge',
        fuga: '{{validJSON5.hoge}}'
      }
    }
    import {fromFiles} from '@hidoo/data-from';
    
    const data = fromFiles('/path/to/*.json5');
    // {data: {hoge: 'hoge', fuga: 'hoge'}}

    Test

    $ npm test

    License

    MIT

    Install

    npm i @hidoo/data-from

    DownloadsWeekly Downloads

    48

    Version

    0.3.1

    License

    MIT

    Unpacked Size

    24.4 kB

    Total Files

    11

    Last publish

    Collaborators

    • hidoo