This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/object-hash/test/replacer.js
2019-08-11 20:48:02 +02:00

36 lines
974 B
JavaScript

'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);
});
});