1.0.3 • Published 3 years ago

crtf v1.0.3

Weekly downloads
7
License
ISC
Repository
github
Last release
3 years ago

crtf

A Playground Library for .crtf Extention

What is CRTF?

CRTF is a file extention for reusing a text file with minor change where one can write a text file along with the few variable which developer can manupulate in time. This library provides an access to read and convert this kind of file into native text or any provided form

Sample .crtf File

Alt text

#output

if object = {
    name : "Piyush",
    date : "29/12/2020",
    description : "Created a file which will update the UI"
}

The output will look like below for above content
OUTPUT:-

/**
 * Created by Piyush on 29/12/2020
 * Created a file which will update the UI
 * Updated by Piyush on 29/12/2020
 * Created a file which will update the UI
*/

Installation

npm install crtf

Features

  • Get the crtf content
  • Replace the crtf content with set of objects
  • Replace and Write to another file with set of objects
  • Get the Variables Associated with crtf

Usage


Creating a CRTF instance

Do not use Contructor for the same

import CRTF from 'crtf';

let crtf;
CRTF.build('path of the crtf file', 'encoding').then(obj => {
    crtf = obj;
    // now crtf is an instance of CRTF
})

or

import CRTF from 'crtf';

let crtf = await CRTF.build('path of the crtf file', 'encoding');

Methods

  • getContent - returns a raw content of the .crtf file
import CRTF from 'crtf';

let crtf = await CRTF.build('path of the crtf file', 'encoding');

let rawContent = crtf.getContent();
  • getVariables - returns a raw variables of the .crtf file
import CRTF from 'crtf';

let crtf = await CRTF.build('path of the crtf file', 'encoding');

let rawContent = crtf.getVariables();
  • replaceContent - returns a replaced content of the .crtf file from given variable objects
import CRTF from 'crtf';

let crtf = await CRTF.build('path of the crtf file', 'encoding');

// for using the sample image above
let obj = {
    name : "Git",
    description : "Git Description"
}

let rawContent = crtf.replaceContent(obj);
  • replaceContentAndWrite - write to file with a replaced content of the .crtf file from given variable objects
import CRTF from 'crtf';

let crtf = await CRTF.build('path of the crtf file', 'encoding');

let writePath = 'your-new-path';

// for using the sample image above
let obj = {
    name : "Git",
    description : "Git Description"
}
let rawContent = crtf.replaceContentAndWrite(writePath, obj);

Hope you like this package. Thanks!

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago