@parischap/conversions
Version:
A functional library to replace partially the native Intl API
106 lines • 2.6 kB
JavaScript
/**
* This module implements a `CVTemplateSeparator` type which is one of the constituents of
* `CVTemplate`'s (see Template.ts and TemplatePart.ts)
*/
import * as MInputError from '@parischap/effect-lib/MInputError';
import * as MInspectable from '@parischap/effect-lib/MInspectable';
import * as MPipeable from '@parischap/effect-lib/MPipeable';
import * as MString from '@parischap/effect-lib/MString';
import * as MTypes from '@parischap/effect-lib/MTypes';
import * as Either from 'effect/Either';
import {pipe} from 'effect/Function';
import * as Predicate from 'effect/Predicate';
import * as Struct from 'effect/Struct';
/**
* Module tag
*
* @category Module markers
*/
export const moduleTag = '@parischap/conversions/TemplateSeparator/';
const _TypeId = /*#__PURE__*/Symbol.for(moduleTag);
/**
* Type guard
*
* @category Guards
*/
export const has = u => Predicate.hasProperty(u, _TypeId);
/** Proto */
const proto = {
[_TypeId]: _TypeId,
[MInspectable.IdSymbol]() {
return this.value;
},
... /*#__PURE__*/MInspectable.BaseProto(moduleTag),
...MPipeable.BaseProto
};
const _make = params => MTypes.objectFromDataAndProto(proto, params);
/**
* Constructor
*
* @category Constructors
*/
export const make = value => _make({
value
});
/**
* Builds a parser that implements this `CVTemplateSeparator`
*
* @category Destructors
*/
export const toParser = self => (pos, text) => {
const value = self.value;
const length = value.length;
return pipe(text, MInputError.assertStartsWith({
startString: value,
name: `remaining text for separator at position ${pos}`
}), Either.map(MString.takeRightBut(length)));
};
/**
* Returns the `value` property of `self`
*
* @category Destructors
*/
export const value = /*#__PURE__*/Struct.get('value');
/**
* Slash Separator instance
*
* @category Instances
*/
export const slash = /*#__PURE__*/make('/');
/**
* Backslash Separator instance
*
* @category Instances
*/
export const backslash = /*#__PURE__*/make('\\');
/**
* Dot Separator instance
*
* @category Instances
*/
export const dot = /*#__PURE__*/make('.');
/**
* Hyphen Separator instance
*
* @category Instances
*/
export const hyphen = /*#__PURE__*/make('-');
/**
* Colon Separator instance
*
* @category Instances
*/
export const colon = /*#__PURE__*/make(':');
/**
* Comma Separator instance
*
* @category Instances
*/
export const comma = /*#__PURE__*/make(',');
/**
* Space Separator instance
*
* @category Instances
*/
export const space = /*#__PURE__*/make(' ');
//# sourceMappingURL=TemplateSeparator.js.map