ref-replace

1.0.3 • Public • Published

Ref Replace npm version

A module that converts $ref in JSON objects and replaces it with _ref so that it can be stored in Mongo, and vice versa.

I made this module because $ref is a standard in JSON and in Mongo.

Usage

import {replaceRefsJSON, replaceRefsMongo} from 'ref-replace';
 
const someJSON = {
  $ref: 'test',
  test: {
    $ref: 'test',
    test: {
      $ref: 'test'
    }
  }
};
 
console.log(replaceRefsJSON(someJSON))
/**
Output:
{
  _ref: 'test',
  test: {
    _ref: 'test',
    test: {
      _ref: 'test'
    }
  }
}
 */
 

License

MIT © Hugo Müller-Downing

Readme

Keywords

Package Sidebar

Install

npm i ref-replace

Weekly Downloads

4

Version

1.0.3

License

MIT

Last publish

Collaborators

  • hugomd