8.1.3 • Published 1 year ago

simple-txt v8.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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

Replace (regex flags, click here to learn javaScript RegExp)

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

Support

Click here to suggestion or report bug.

Copyright © 2023 Mustafa ALGhanim - Mr Dark

7.7.3

1 year ago

7.7.2

1 year ago

8.0.1

1 year ago

8.0.0

1 year ago

8.1.2

1 year ago

8.1.3

1 year ago

7.5.1

3 years ago

7.5.0

3 years ago

5.0.1

3 years ago

7.3.0

3 years ago

7.1.0

3 years ago

4.7.0

3 years ago