1.0.0 • Published 2 years ago

@cristalnaya/chops v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Introduction

The chop method is a TypeScript method that accepts two parameters: template and dataset. The method is designed to render template, replacing {{x}} with data[x], and return the resulting string.

Requirements

  • The dataset parameter only accepts objects.
  • The template parameter must only accept strings.
  • Both parameters are mandatory. If the method chop is called but missing one of the parameters, and error with "template and dataset are mandatory parameters" is returned.
  • The dataset should only support & number values. If other types are provided, a useful error is given.

Usage

To use the chop method, simply import it and provide the template and dataset parameters, then call the method:

import {chop} from '@cristalnaya/chops/src/chop';

const dataset = {
    bread: 'baguette',
    cheese: 'brie cheese',
}
const template = 'I like to eat {{bread}} and {{cheese}}';

chop(template, dataset);

Testing

The method chop has been tested using Jest. To run the tests, simply run the following command in your terminal:

npm run test

Tools used

  • TypeScript
  • Jest
  • ts-jest
  • prettier
  • @types/jest
  • @types/node
  • eslint
  • GitHub Actions
1.0.0

2 years ago