txt-editor

1.0.0 • Public • Published

txt-editor

test
A modular text based AI module for javascript and node js

How To Use

Editing TxtSetting

const { TxtSetting, TxtFileEditor, StringEditor } = require('@visualarchive/txt-editor');

TxtSetting.Separator = '\n' // Is the chunk separator.
TxtSetting.Default() // resets the settings to default

Editing a .txt File

⚠ Warning:
Make sure to use editor.Save() after to save the edit to the text file or you can save it as its string form with editor.Output.

To edit a text file using txt-editor require the @visualarchive/txt-editor packet from the npm and create a new TxtFileEditor class.

const { TxtSetting, TxtFileEditor, StringEditor } = require('@visualarchive/txt-editor');

const editor = TxtFileEditor.build(PATH);
  • PATH is the directory to the .txt file you want to use.

Prefixes, Suffixes, and Replace

Using ChunkPrefix, ChunkSuffix, FindReplace alows you to edit text in the text file.

editor.ChunkPrefix(STRING);

editor.ChunkSuffix(STRING);

editor.FindReplace(FIND, REPLACE , MAX);
  • STRING is the value that will be used as the prefix/sufix.
  • FIND is the value that will be replaced.
  • REPLACE is the value that will replace the FIND value.
  • MAX is the max cap you want for replaces (leave blank for inf).

Inserting, Removing, and Saving

Using Insert, Remove, Save alows you to more precisely edit the text file.

editor.Insert(INDEX, TEXT);

editor.Remove(MININDEX, MAXINDEX);

editor.Save();
  • INDEX is the value that text will go in.
  • MININDEX is the value that will be the starting point index zone.
  • MAXINDEX is the value that will be the ending point index zone.
  • TEXT is the value that will replace the the values in the index zone.

Editing a String

To edit a text file using txt-editor require the @visualarchive/txt-editor packet from the npm and create a new StringEditor class.

const { TxtSetting, TxtFileEditor, StringEditor } = require('@visualarchive/txt-editor');

const editor = StringEditor.build(STRING);
  • STRING is the string you want to edit like a text file.

Prefixes, Suffixes, and Replace

Using ChunkPrefix, ChunkSuffix, FindReplace alows you to edit text in the text file.

editor.ChunkPrefix(STRING);

editor.ChunkSuffix(STRING);

editor.FindReplace(FIND, REPLACE , MAX);
  • STRING is the value that will be used as the prefix/sufix.
  • FIND is the value that will be replaced.
  • REPLACE is the value that will replace the FIND value.
  • MAX is the max cap you want for replaces (leave blank for inf).

Inserting and Removing

Using Insert, Remove alows you to more precisely edit the text file.

editor.Insert(INDEX, TEXT);

editor.Remove(MININDEX, MAXINDEX);
  • INDEX is the value that text will go in.
  • MININDEX is the value that will be the starting point index zone.
  • MAXINDEX is the value that will be the ending point index zone.
  • TEXT is the value that will replace the the values in the index zone.

Summary

--Properties--

StringEditor

Properties Info
Output: String The output unsaved data of StringEditor.
READ ONLY
Prefix: String The prefix before the chunk.
READ ONLY
Suffix: String The suffix after the chunk.
READ ONLY

TxtFileEditor

Properties Info
Output: String The output unsaved data of TxtFileEditor.
READ ONLY
Prefix: String The prefix before the chunk.
READ ONLY
Suffix: String The suffix after the chunk.
READ ONLY
Path: String The path to the text file.
READ ONLY

TxtSetting

Properties Info
Separator: String The chunk separator.
‎ㅤ

--Methods--

StringEditor

Properties
ChunkPrefix(STRING: String): void
_____________________________________________________________________________________
The text added at the beginning of the chunk.
ChunkSuffix(STRING: String): void
_____________________________________________________________________________________
The text added at the end of the chunk.
FindReplace(FIND: String, REPLACE: String , MAX: Intger): void
_____________________________________________________________________________________
Finds and replaces text.
Insert(INDEX: Intger, TEXT: String): void
_____________________________________________________________________________________
Removes the text in the index zone.
Remove(MININDEX: Intger, MAXINDEX: Intger): void
_____________________________________________________________________________________
Removes the text in the index zone.

TxtFileEditor

Properties
ChunkPrefix(STRING: String): void
_____________________________________________________________________________________
The text added at the beginning of the chunk.
ChunkSuffix(STRING: String): void
_____________________________________________________________________________________
The text added at the end of the chunk.
FindReplace(FIND: String, REPLACE: String , MAX: Intger): void
_____________________________________________________________________________________
Finds and replaces text.
Insert(INDEX: Intger, TEXT: String): void
_____________________________________________________________________________________
Removes the text in the index zone.
Remove(MININDEX: Intger, MAXINDEX: Intger): void
_____________________________________________________________________________________
Removes the text in the index zone.
Save(): void
_____________________________________________________________________________________
Saves the changes from the TxtFileEditor.

TxtSetting

Properties
Default(): void
_____________________________________________________________________________________
Sets settings to default.

Contact
o visualarchive
Made With
ooo

Readme

Keywords

Package Sidebar

Install

npm i txt-editor

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

17.2 kB

Total Files

3

Last publish

Collaborators

  • visualarchive