🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

file-content-reader

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-content-reader

file content reader

latest
Source
npmnpm
Version
1.0.6
Version published
Maintainers
2
Created
Source

File content reader

This package can read any type of files and make object of KV, where Key is equal path and Value is file content. Additional feature is insert critical css to the html in SSR react, here is example repository.

Example:

  const { collectFileContent } = require('file-content-reader');
  const filesContent = collectFileContent(path.resolve(process.cwd() + '/src'), ['.css', '.js', '.md'], 'utf8');
  // Output
  {
    css: [
      { 
        name: "/app.css",
        fullName: "/Users/user/projects/simple-ssr/src/app.css",
        content:  "./src/styles.css": "body {\n  margin: 0;\n  padding: 28px 16px;\n}"
      }
    ],
    js: [
      { 
        name: "./src/index.js",
        fullName: "/Users/user/projects/simple-ssr/src/index.js",
        content: "
          import React from 'react';\n" +
          "import './component.css';\n" +
          '\n' +
          'export default () => (\n' +
          '  <div>\n' +
          '   Hello world !!!\n' +
          '  </div>\n' +
          ');\n"
      }
    ],
    md: [
      { 
        name: "/README.md",
        fullName: "/Users/user/projects/simple-ssr/src/README.md",
        content: "
          '## File content reader\n' +
          '\n' +
          'This package can read any type of files and make object of KV\n' +
          '```\n"
      }
    ]
  ]

Supported features

  • Any type of files
  • Lru cache

Keywords

file reader

FAQs

Package last updated on 29 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts