@htmlacademy/serializer

## Как сериализовать объект

Stats

StarsIssuesVersionUpdatedCreatedSize
@htmlacademy/serializer
1.0.112 years ago4 years agoMinified + gzip package size for @htmlacademy/serializer in KB

Readme

serializer

Как сериализовать объект

В виде строки (без отступов)

var getSerializer = require('@htmlacademy/serializer/lib/serializer');
var getBaseEmitter = require('@htmlacademy/serializer/lib/base-emitter');

var serialize = getSerializer(getBaseEmitter());

var string = serialize({obj: {}, fn: () => {}, num: 42, bool: true});
// => "{obj: {}, fn: () => {...}, num: 42, bool: true}"

В виде строки (с отступами)

var getSerializer = require('@htmlacademy/serializer/lib/serializer');
var getIndentingEmitter = require('@htmlacademy/serializer/lib/indenting-emitter');

var serialize = getSerializer(getIndentingEmitter());

var string = serialize({obj: {}, fn: () => {}, num: 42, bool: true});

/* =>
`
{
  obj: {
  },
  fn: () => {...},
  num: 42,
  bool: true
}
`
*/

В виде html-разметки

var getSerializer = require('@htmlacademy/serializer/lib/serializer');
var getHtmlEmitter = require('@htmlacademy/serializer/lib/html-emitter');

var serialize = getSerializer(getHtmlEmitter());

var string = serialize({obj: {}, fn: () => {}, num: 42, bool: true});

/* =>
`
<span class="symbol">{</span>
  obj<span class="symbol">:</span> <span class="symbol">{</span>
  <span class="symbol">}</span><span class="symbol">,</span>
  fn<span class="symbol">:</span> <span class="function">() => {...}</span><span class="symbol">,</span>
  num<span class="symbol">:</span> <span class="number">42</span><span class="symbol">,</span>
  bool<span class="symbol">:</span> <span class="boolean">true</span>
<span class="symbol">}</span>
`
*/

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.