1.6.14 • Published 6 years ago

js2txt v1.6.14

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

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'}}
1.6.14

6 years ago

1.6.11

6 years ago

1.5.20

6 years ago

1.5.6

6 years ago

1.4.24

6 years ago

1.4.20

6 years ago