txt-editor
v1.0.0
Published
Basic text/.txt edit
Downloads
3
Readme
txt-editor
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 defaultEditing a .txt File
⚠ Warning:
Make sure to useeditor.Save()after to save the edit to the text file or you can save it as its string form witheditor.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);PATHis the directory to the.txtfile 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);STRINGis the value that will be used as the prefix/sufix.FINDis the value that will be replaced.REPLACEis the value that will replace theFINDvalue.MAXis 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();INDEXis the value that text will go in.MININDEXis the value that will be the starting point index zone.MAXINDEXis the value that will be the ending point index zone.TEXTis 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);STRINGis 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);STRINGis the value that will be used as the prefix/sufix.FINDis the value that will be replaced.REPLACEis the value that will replace theFINDvalue.MAXis 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);INDEXis the value that text will go in.MININDEXis the value that will be the starting point index zone.MAXINDEXis the value that will be the ending point index zone.TEXTis the value that will replace the the values in the index zone.
Summary
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. ㅤ|
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 visualarchive|Made With
|
|:---:|:---:|
