1 Star 0 Fork 0

animalcoder/Vue

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
replacer.js 974 Bytes
一键复制 编辑 原始数据 按行查看 历史
animalcoder 提交于 2020-03-17 14:52 +08:00 . Vueinit
'use strict';
var assert = require('assert');
var stream = require('stream');
var hash = require('../index');
describe('replacer option', function() {
it('should emit information about an object to a stream', function() {
var strm = new stream.PassThrough();
var replacer = function(value) {
try {
return JSON.stringify(value);
} catch (e) {
return value;
}
};
var obj = {foo: 'bar'};
hash.writeToStream(obj, {replacer: replacer}, strm);
var result = strm.read().toString();
assert.strictEqual(typeof result, 'string');
assert.notStrictEqual(result.indexOf(JSON.stringify(obj)), -1);
});
it('should not reach property values when excludeValues = true', function() {
var strm = new stream.PassThrough();
var replacer = function(k) {
assert.notStrictEqual(k, 'bar');
return k;
};
hash.writeToStream({foo: 'bar'}, {excludeValues: true}, strm);
});
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/animalcoder/Vue.git
git@gitee.com:animalcoder/Vue.git
animalcoder
Vue
Vue
master

搜索帮助