@statlertronik/ids-to-path-string
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@statlertronik/ids-to-path-string

Helper utility generate key strings for REST API from array of key values.

How to use it

to install:

npm install @statlertronik/ids-to-path-string

in code (typescript):

/*--------------------------------------------------------------------*/
/* Creating 'Collection+JSON' response object with collection data    */
/* and with references to 'queries' & 'template' objects.             */
/*--------------------------------------------------------------------*/
import { 
    KeyValueType,
    ids2PathString
    } from '@statlertronik/ids-to-path-string';

cost ids: KeyValueType[] = ["John", 123];
const key: string = ids2PathString(ids);         // returns: "John_123"
...

API

type KeyValueType = string | number | boolean;

ids2PathString(ids: KeyValueType[]): string

Function builds REST API path identifier for multicolumn key. It takes array of values and if a value is string then escapes it, otherwise converts to string and separates them with '_'

Parameters

Name Meaning
ids array of identifiers

Readme

Keywords

none

Package Sidebar

Install

npm i @statlertronik/ids-to-path-string

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

2.95 kB

Total Files

6

Last publish

Collaborators

  • ddziara