js2txt

1.6.14 • Public • Published

js2txt

‘js2txt’ works just like JSON.stringify, but it also supports functions. Works in both Node.js and the browser. Lightweight. No dependencies.

Install

NPM

npm install js2txt

CDN

<script type="text/javascript" src="https://cdn.rawgit.com/jackens/js2txt/master/js2txt.js"></script>

or

<script type="text/javascript" src="https://cdn.rawgit.com/jackens/js2txt/master/js2txt.min.js"></script>

or

<script type="text/javascript" src="https://unpkg.com/js2txt/js2txt.js"></script>

or

<script type="text/javascript" src="https://unpkg.com/js2txt/js2txt.min.js"></script>

Usage

var js2txt = require('js2txt')

var js = {
  array: ['a', 'r', 'r', 'a', 'y'],
  function: function (arg) {
    console.log(arg)
  },
  null: null,
  number: 42,
  object: {
    string: 'string'
  }
}
console.log(JSON.stringify(js))
console.log(js2txt(js))

generates the following output:

{"array":["a","r","r","a","y"],"null":null,"number":42,"object":{"string":"string"}}
{array:['a','r','r','a','y'],function:function (arg) {
    console.log(arg)
  },null:null,number:42,object:{string:'string'}}

Readme

Keywords

Package Sidebar

Install

npm i js2txt

Weekly Downloads

0

Version

1.6.14

License

ISC

Unpacked Size

4.82 kB

Total Files

6

Last publish

Collaborators

  • npm