1.1.0 • Published 6 years ago

object-chain v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

object-chain

Create objects with chainable properties

Usage

playground

const objectChain = require('object-chain');

const match = objectChain({
  beginningOfInput: '^',
  endOfInput: '$',
  anySingleCharExceptTheNewline: '.',
  zeroOrMoreTimes: '*',
  oneOrMoreTimes: '+',
  zeroOrOneTime: '?',
  or: '|',
  escapeChar: '\\',
  backslash: '\\',
  backspace: '\\b',
  nonWordBoundary: '\\B',
  digit: '\\d',
  nonDigitChar: '\\D',
  formFeed: '\\f',
  lineFeed: '\\n',
  carriageReturn: '\\r',
  whiteSpace: '\\s',
  tab: '\\t',
  verticalTab: '\\v',
  alphanumericChar: '\\w',
  nonWordChar: '\\W',
  nil: '\\0',
  lowerCase: '[a-z]',
  upperCase: '[A-Z]',
  letter: '[a-zA-Z]',
  number: '[0-9]',
  varchar: '[$0-9A-Za-z_\\s]',
  pathChar: '[@$0-9a-zA-Z_\\s-.\\/]',
  value: (self, last, value) => `${self}${value}`,
  controlChar: (self, last, value) => `${self}\\c${value}`,
  notRemember: (self, last, value) => `${self}(?:${value})`,
  ifFollowedBy: (self, last, value) => `${self}(?=${value})`,
  ifNotFollowedBy: (self, last, value) => `${self}(?!${value})`,
  notCharset: (self, last, value) => `${self}[^${value}]`,
  charset: (self, last, value) => `${self}[${value}]`,
  size: (self, last, value) => `${self}{${value>>>0}}`,
  atLeast: (self, last, value) => `${self}{${value>>>0},}`,
  atMost: (self, last, value) => `${self}{,${value>>>0}}`,
  group: (self, last, value) => `${self}(${value})`,
  range: (self, last, min, max) => `${self}{${min>>>0},${max>>>0}}`,
  flags: (self, last, value) => new RegExp(self, value),
});

const matchId = match.beginningOfInput.varchar.range(3, 8).endOfInput.flags('i');
const rId = matchId();

rId.test('abc');
1.1.0

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago