Skip to content

Librairie facilitant l'utilisation de fichiers texte en JavaScript

Notifications You must be signed in to change notification settings

ant-oss/file_reader_writer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

file_reader_writer

Librairie facilitant l'utilisation de fichier texte en JavaScript

Importation

Pour importer la librairie située dans le dossier dist :

<script src="dist/filereader.js"></script>

Utilisation

Lecture de fichiers

var reader = new TextFileReader();

À partir d'un <input type="file">, il est possible de lire le texte contenu dans le fichier importé :

<input type="file" id="fichier">
var reader = new TextFileReader();
var input = document.getElementById("fichier");
input.onchange = async function() {
  console.log(await (reader.readTextFromInput(input)));
}

Ecriture dans des fichiers

var writer = new TextFileWriter();

Pour enregistrer le fichier nommé test.txt avec comme contenu hello world :

var writer = new TextFileWriter();
const texte = "hello world";
const nomFichier = "test.txt";
writer.saveAsText(texte, nomFichier);

About

Librairie facilitant l'utilisation de fichiers texte en JavaScript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published