Skip to content

You can easily modify, add, check for a specific text or delete the entire txt file content, without complications.

Notifications You must be signed in to change notification settings

MuALG/simple-txt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

You can easily modify, add, check for a specific text or delete the entire txt file content, without complications.

Installation

npm i simple-txt

Setup

const stxt = require("simple-txt")

const txt = new stxt('test'); // file name



Set:

index.js

txt.set('hello world'); // true

Get:

index.js

txt.get(); // hello world

Add (default)

index.js

txt.add('hello');
txt.add('world');

Result:

test.txt

hello
world



Add (no)

index.js

txt.add('hello');
txt.add('world', 'no');

Result:

test.txt

hello world



Add (top)

index.js

txt.add('hello');
txt.add('world', 'top');

Result:

test.txt

world
hello



Has (default)

test.txt

world
hello

index.js

txt.has('world'); // true



Has (index)

test.txt

world
hello

index.js

txt.has('world','index'); // 7

or

txt.has('world','i'); // 7



Replace (default)

test.txt

hello tomas

index.js

txt.replace('tomas','world'); // true

Result:

test.txt

hello world



test.txt

hello ToMAs
hi tomas
txt.replace('tomas','world', 'gi');

Result:

test.txt

hello world
hi world



Length (default)

test.txt

hello world

index.js

txt.length(); // 11



Length (word)

test.txt

hello world

index.js

txt.length('word'); // 2

or

txt.length('w'); // 2



Length (line)

test.txt

1| hello
2| world
3| ..
4| bye

index.js

txt.length('line'); // 4

or

txt.length('l'); // 4



Clear

index.js

txt.clear(); // true

Copyright © 2023 Mustafa ALGhanim - Mr Dark

About

You can easily modify, add, check for a specific text or delete the entire txt file content, without complications.

Resources

Stars

Watchers

Forks

Packages

No packages published