0.3.4 • Published 9 years ago

remarks v0.3.4

Weekly downloads
6
License
MIT
Repository
github
Last release
9 years ago

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

0.3.4

9 years ago

0.3.3

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago