8.1.3 • Published 3 years ago
simple-txt v8.1.3
You can easily modify, add, check for a specific text or delete the entire txt file content, without complications.
Installation
npm i simple-txtSetup
const stxt = require("simple-txt")
const txt = new stxt('test'); // file nameSet:
index.js
txt.set('hello world'); // trueGet:
index.js
txt.get(); // hello worldAdd (default)
index.js
txt.add('hello');
txt.add('world');Result:
test.txt
hello
worldAdd (no)
index.js
txt.add('hello');
txt.add('world', 'no');Result:
test.txt
hello worldAdd (top)
index.js
txt.add('hello');
txt.add('world', 'top');Result:
test.txt
world
helloHas (default)
test.txt
world
helloindex.js
txt.has('world'); // trueHas (index)
test.txt
world
helloindex.js
txt.has('world','index'); // 7or
txt.has('world','i'); // 7Replace (default)
test.txt
hello tomasindex.js
txt.replace('tomas','world'); // trueResult:
test.txt
hello worldReplace (regex flags, click here to learn javaScript RegExp)
test.txt
hello ToMAs
hi tomastxt.replace('tomas','world', 'gi');Result:
test.txt
hello world
hi worldLength (default)
test.txt
hello worldindex.js
txt.length(); // 11Length (word)
test.txt
hello worldindex.js
txt.length('word'); // 2or
txt.length('w'); // 2
Length (line)
test.txt
1| hello
2| world
3| ..
4| byeindex.js
txt.length('line'); // 4or
txt.length('l'); // 4
Clear
index.js
txt.clear(); // trueSupport
Click here to suggestion or report bug.
Copyright © 2023 Mustafa ALGhanim - Mr Dark