remarks
TypeScript icon, indicating that this package has built-in type declarations

0.3.4 • Public • Published

Remarks

Simple two-way conversion and maintenance of JSON comments

Installation

npm install --save remarks

Sample usage

/* Optionally takes a JSON string that should be an array */
 
var remarks;
 
// Example using knex
knex('post').select().where('id', id)
    .then(post => new Remarks(post.comments))
    .then(r => remarks = r);
 
// meanwhile, some time later...
 
remarks.add({ name: 'seikho', comment: 'i love remarks' });
 
knex('post')
    .update({ comments: remarks.toString() })
    .where('id', 'id');
    .then(() => console.log('updated'));

API

constructor

constructor(json?: string)

add

Add a comment to the list of comments

function add(comment: T): void;

parse

Re-populate the array with entirely new comments

function parse(json: string): void;

toArray

Return a copy of the comments array

function toArray(): Array<T>;

toString

Return the comments as a JSON string

function toString(): string;

License

MIT

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i remarks

    Weekly Downloads

    11

    Version

    0.3.4

    License

    MIT

    Last publish

    Collaborators

    • seikho