json-streamify:node.js 的“JSON.stringify”的流媒体版本

  • d6_185715
    了解作者
  • 4.9KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-09 10:32
    上传日期
JSON 流化 JSON.stringify的流媒体版本。 npm install json-streamify 方法 streamify(object, function) 传递对象的函数块,直到没有对象为止。 streamify是一个同步函数。 var assert = require('assert') , streamify = require('../streamify').streamify , streamingWrite = require('../streamify').streamingWrite , fs = require('fs') , object = { a: 1, b: 2, c: 3} var str = ''; streamify(object, function(data) { str += data; }); consol
json-streamify-master.zip
  • json-streamify-master
  • .gitignore
    13B
  • test
  • test.js
    3.7KB
  • examples
  • example.js
    470B
  • LICENSE
    1KB
  • package.json
    658B
  • streamify.js
    1.4KB
  • readme.md
    1.3KB
  • .travis.yml
    84B
内容介绍
# JSON Streamify [![Build Status](https://travis-ci.org/DTrejo/json-streamify.png)](http://travis-ci.org/DTrejo/json-streamify) A streaming version of `JSON.stringify`. npm install json-streamify ## Methods ### `streamify(object, function)` Passes the function chunks of the object until there is none of the object left. `streamify` is a synchronous function. var assert = require('assert') , streamify = require('../streamify').streamify , streamingWrite = require('../streamify').streamingWrite , fs = require('fs') , object = { a: 1, b: 2, c: 3} var str = ''; streamify(object, function(data) { str += data; }); console.log(str); // => {"a":1,"b":2,"c":3} ### `streamingWrite(filepath, object, callback)` Writes chunks of the object to the given filepath until there is none of the object left. When it finishes, it calls `callback`. var str = ''; streamingWrite('./ACOOLFILE.txt', object, function(data) { str += data; }, function() { console.log(fs.readFileSync('./ACOOLFILE')); // => {"a":1,"b":2,"c":3} }); Most of this was written by [James Halliday](http://substack.net), with a few small things by [David Trejo](http://dtrejo.com/). ### TODOs - allow a stream to be passed into `streamify(object, stream)`?
评论
    相关推荐