npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@chubbyts/chubbyts-decode-encode

v1.3.3

Published

A simple decode/encode solution for json / jsonx / url-encoded / xml / yaml.

Downloads

508

Readme

chubbyts-decode-encode

CI Coverage Status Infection MSI npm-version

bugs code_smells coverage duplicated_lines_density ncloc sqale_rating alert_status reliability_rating security_rating sqale_index vulnerabilities

Description

A simple decode/encode solution for json / jsonx / url-encoded / xml / yaml.

Requirements

Installation

Through NPM as @chubbyts/chubbyts-decode-encode.

npm i @chubbyts/chubbyts-decode-encode@^1.3.3

Usage

Decoder

createDecoder

import { createDecoder } from '@chubbyts/chubbyts-decode-encode/dist/decoder';
import { createJsonTypeDecoder } from '@chubbyts/chubbyts-decode-encode/dist/decoder/json-type-decoder';

const decoder = createDecoder([createJsonTypeDecoder()]);
const data = decoder.decode('{"key":"value"}', 'application/json'); // or with 3th argument, for example { user: 'username1' }
// data: {key: "value"}
const contentTypes = decoder.contentTypes;
// contentTypes: ['application/json']

createJsonTypeDecoder

import { createJsonTypeDecoder } from '@chubbyts/chubbyts-decode-encode/dist/decoder/json-type-decoder';

const jsonTypeDecoder = createJsonTypeDecoder();
const data = jsonTypeDecoder.decode('{"key":"value"}');
// data: {key: "value"}
const contentType = jsonTypeDecoder.contentType;
// contentType: 'application/json'

createJsonxTypeDecoder

import { createJsonxTypeDecoder } from '@chubbyts/chubbyts-decode-encode/dist/decoder/jsonx-type-decoder';

const jsonxTypeDecoder = createJsonxTypeDecoder();
const data = jsonxTypeDecoder.decode(`
<?xml version="1.0" encoding="UTF-8"?>
<json:object>
  <json:string name="key">value</json:string>
</json:object>
`);
// data: {key: "value"}
const contentType = jsonxTypeDecoder.contentType;
// contentType: 'application/jsonx+xml'

createUrlEncodedTypeDecoder

import { createUrlEncodedTypeDecoder } from '@chubbyts/chubbyts-decode-encode/dist/decoder/url-encoded-type-decoder';

const urlEncodedTypeDecoder = createUrlEncodedTypeDecoder();
const data = urlEncodedTypeDecoder.decode('key=value');
// data: {key: "value"}
const contentType = urlEncodedTypeDecoder.contentType;
// contentType: 'application/x-www-form-urlencoded'

createYamlTypeDecoder

import { createYamlTypeDecoder } from '@chubbyts/chubbyts-decode-encode/dist/decoder/yaml-type-decoder';

const yamlTypeDecoder = createYamlTypeDecoder();
const data = yamlTypeDecoder.decode('key: value');
// data: {key: "value"}
const contentType = yamlTypeDecoder.contentType;
// contentType: 'application/x-yaml'

Encoder

createEncoder

import { createEncoder } from '@chubbyts/chubbyts-encode-encode/dist/encoder';
import { createJsonTypeEncoder } from '@chubbyts/chubbyts-encode-encode/dist/encoder/json-type-encoder';

const encoder = createEncoder([createJsonTypeEncoder()]);
const encodedData = encoder.encode({key: "value"}, 'application/json'); // or with 3th argument, for example { user: 'username1' }
// encodedData: {"key":"value"}
const contentTypes = encoder.contentTypes;
// contentTypes: ['application/json']

createJsonTypeEncoder

import { createJsonTypeEncoder } from '@chubbyts/chubbyts-encode-encode/dist/encoder/json-type-encoder';

const jsonTypeEncoder = createJsonTypeEncoder();
const encodedData = jsonTypeEncoder.encode({key: "value"});
// encodedData: {"key":"value"}
const contentType = jsonTypeEncoder.contentType;
// contentTypes: 'application/json'

createJsonxTypeEncoder

import { createJsonxTypeEncoder } from '@chubbyts/chubbyts-encode-encode/dist/encoder/jsonx-type-encoder';

const jsonxTypeEncoder = createJsonxTypeEncoder();
const encodedData = jsonxTypeEncoder.encode({key: "value"});
// encodedData: <?xml version="1.0" encoding="UTF-8"?>
// <json:object>
//   <json:string name="key">value</json:string>
// </json:object>
const contentType = jsonxTypeEncoder.contentType;
// contentTypes: 'application/jsonx+xml'

createUrlEncodedTypeEncoder

import { createUrlEncodedTypeEncoder } from '@chubbyts/chubbyts-encode-encode/dist/encoder/url-encoded-type-encoder';

const urlEncodedTypeEncoder = createUrlEncodedTypeEncoder();
const encodedData = urlEncodedTypeEncoder.encode({key: "value"});
// encodedData: key=value
const contentType = urlEncodedTypeEncoder.contentType;
// contentTypes: 'application/x-www-form-urlencoded'

createYamlTypeEncoder

import { createYamlTypeEncoder } from '@chubbyts/chubbyts-encode-encode/dist/encoder/yaml-type-encoder';

const yamlTypeEncoder = createYamlTypeEncoder();
const encodedData = yamlTypeEncoder.encode({key: "value"});
// encodedData: key: value
const contentType = yamlTypeEncoder.contentType;
// contentTypes: 'application/x-yaml'

Copyright

2023 Dominik Zogg