2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
8 const { register } = require("../util/serialization");
12 this._buffer = undefined;
13 this._data = undefined;
14 if (Buffer.isBuffer(data)) {
22 if (this._data === undefined && this._buffer !== undefined) {
23 this._data = JSON.parse(this._buffer.toString());
29 if (this._buffer === undefined && this._data !== undefined) {
30 this._buffer = Buffer.from(JSON.stringify(this._data));
33 if (this._buffer) return hash.update(this._buffer);
37 register(JsonData, "webpack/lib/json/JsonData", null, {
38 serialize(obj, { write }) {
39 if (obj._buffer === undefined && obj._data !== undefined) {
40 obj._buffer = Buffer.from(JSON.stringify(obj._data));
44 deserialize({ read }) {
45 return new JsonData(read());
49 module.exports = JsonData;