JSPM

sort-key

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 38
  • Score
    100M100P100Q74803F
  • License MIT

Tiny library for generating and parsing DynamoDB sort keys.

Package Exports

  • sort-key

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sort-key) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

🔑 Sort-Key

Tiny library for generating and parsing DynamoDB sort keys.

View On NPM Build Status Dependency Status Coverage Status License


Generating DynamoDB sort keys from multiple string parts as recommended by AWS. It uses # as separator and knows how to escape it when given on one of the key parts.

[country]#[region]#[state]#[county]#[city]#[neighborhood]

Install

npm i sort-key

Usage

import SortKey from 'sort-key';

const SK = SortKey.generate('1532208', '2020-09-11T15:30:06.822Z');
// 1532208#2020-09-11T15:30:06.822Z

const [order, time] = SortKey.parse(SK);
// "1532208" "2020-09-11T15:30:06.822Z"

It supports escaping as well:

const SK = SortKey.generate('example.com', 'foo', 'https://example.com/foo/bar#top');
// example.com#foo#https://example.com/foo/bar\#top

const [domain, page, url] = SortKey.parse(SK);
// "example.com" "foo" "https://example.com/foo/bar#top"

License

MIT license © 2020 Neuledge