Giter Club home page Giter Club logo

read-file-string's Introduction

read-file-string

License Sponsor read-file-string
Build status Commits since v1.1.2 Last commit Issues
Latest version on npm Dependents Downloads

Returns file content as a UTF-8 string. Returns null if file does not exist (or is a directory) instead of throwing an Error.

Installation

read-file-string on npm

npm install --save read-file-string@^1.1.2

read-file-string on Yarn

yarn add read-file-string@^1.1.2

@jaid/read-file-string on GitHub Packages
(if configured properly)

npm install --save @jaid/read-file-string@^1.1.2

Example

import readFileString from "read-file-string"

readFileString("./existingFile.txt").then(result => {

})

readFileString("./doesNotExist.txt").then(result2 => {

})

Variable result will be:

"the file contents"

Variable result2 will be:

null

Development

Setting up:

git clone [email protected]:jaid/read-file-string.git
cd read-file-string
npm install

Testing:

npm run test:dev

Testing in production environment:

npm run test

License

MIT License
Copyright © 2021, Jaid <[email protected]> (https://github.com/jaid)

read-file-string's People

Contributors

actions-user avatar github-actions[bot] avatar jaid avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

read-file-string's Issues

Unable to get proper string from file while reading

I was reading a file nme al.txt which has txt as

my name is himanshu joshi
Algolia is a great search tool.

but on read using readFileStringSync I was getting something like this

F�Qword/numbering.xml��MN�0�O�"��$ 5�
6����X�=��I��q��R$��U��������Kɠ�h��ˈ\3Ȅ.R���x"�uTgT��)9rK���u��J�9�}�Gh�(���9���e%W�.�p�9���/�Ce
                                                                                                ��N�����tHI�:�
                                                                                                              %��ܝ$     �`���
���Jv�*ŵ;;�ȥ��-��=Mͥ�b�C�Q+��k��
                               i��dk�f�qk��][�q4a�'Ġ���OϾE�0�t\����vF�ga�F�қ�#���.�y^ꍘ��+�W�
PIChF�Qword/settings.xml���n�0U\�Kj�H+�G{E����9��?�X��p�
                              ǟ`����I6uzX�����=#ɶ}A����'ǖդ@�f�H�?�

which I don't want.

Also can we also make to it get data as json base on section of files?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.