Writing code

FUNCTION

toAnyStringExceptPattern

@skmtc/lang-typescript 0.19.1

A pattern that matches any string except the given names, each matched exactly. A record beside named properties uses it as its key: the record then checks only the keys the properties do not name.

With no names, every string matches, and the pattern is empty.

Signature

import { toAnyStringExceptPattern } from '@skmtc/lang-typescript'

toAnyStringExceptPattern(args: ToAnyStringExceptPatternArgs): string

Parameters

args, ToAnyStringExceptPatternArgs required
names, string[] required

The strings the pattern must not match, as written (they are escaped here).

Example
toAnyStringExceptPattern({ names: ['id', 'a.b'] }) // '^(?!(?:id|a\\.b)$)'
toAnyStringExceptPattern({ names: [] })            // ''

Returns

string