1.1.0 • Published 9 months ago

@abhijith_213-/js-file-magic-number-checker v1.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

Table of Contents

Functions

Functions getFileType(fileSignature: string): string

Returns the corresponding file type for a given magic number (file signature). getFileTypeFromEvent(event: Event): Promise

Returns a promise that resolves to the detected file type from a file input change event.

Installation

npm install @abhijith_213-/js-file-magic-number-checker

Usage

    Import the necessary functions:

javascript

import { getFileTypeFromEvent } from '@abhijith_213-/js-file-magic-number-checker';

    Use the getFileTypeFromEvent function to determine the file type from a file input change event:

javascript

import React, { useState } from 'react';
import { getFileTypeFromEvent } from '@abhijith_213-/js-file-magic-number-checker';

function App() {
  const [fileType, setFileType] = useState('');

  const handleFileChange = async (event) => {
    const fileType = await getFileTypeFromEvent(event);
    setFileType(fileType);
  };

  return (
    <div>
      <h1>File Magic Number Checker</h1>
      <input type="file" onChange={handleFileChange} />
      {fileType && <p>Detected File Type: {fileType}</p>}
    </div>
  );
}

export default App;
1.1.0

9 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago