Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/seikho/remarks
JSON comments handling
https://github.com/seikho/remarks
Last synced: 5 days ago
JSON representation
JSON comments handling
- Host: GitHub
- URL: https://github.com/seikho/remarks
- Owner: Seikho
- Created: 2015-10-06T01:24:49.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-18T06:12:22.000Z (about 9 years ago)
- Last Synced: 2024-10-30T07:58:50.380Z (8 days ago)
- Language: JavaScript
- Size: 156 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
### Remarks
Simple two-way conversion and maintenance of JSON comments### Installation
```
npm install --save remarks
```### Sample usage
```javascript
/* 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
```javascript
constructor(json?: string)
```#### add
Add a comment to the list of comments
```javascript
function add(comment: T): void;
```#### parse
Re-populate the array with entirely new comments
```javascript
function parse(json: string): void;
```#### toArray
Return a copy of the comments array
```javascript
function toArray(): Array;
```#### toString
Return the comments as a JSON string
```javascript
function toString(): string;
```### License
MIT