Socket
Socket
Sign inDemoInstall

ref-replace

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ref-replace

Replace JSON references with _ref so that the object can be inserted into Mongo


Version published
Maintainers
1
Install size
2.24 kB
Created

Readme

Source

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

Keywords

FAQs

Last updated on 09 Aug 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc