Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
@types/file-saver
Advanced tools
TypeScript definitions for FileSaver.js
The @types/file-saver package provides TypeScript type definitions for the file-saver package, which is a JavaScript library that enables saving files on the client-side. It is useful for applications that need to generate and download files directly in the browser without sending them to a server first. The type definitions allow TypeScript developers to use file-saver with type checking and IntelliSense support in their IDEs.
Saving text files
This feature allows you to save text files. The code sample demonstrates how to create a text file with the content 'Hello, world!' and save it as 'hello.txt'.
import { saveAs } from 'file-saver';
const data = new Blob(['Hello, world!'], { type: 'text/plain;charset=utf-8' });
saveAs(data, 'hello.txt');
Saving binary files
This feature allows you to save binary files. The code sample shows how to create a binary file from an array of bytes and save it as 'binaryFile.bin'.
import { saveAs } from 'file-saver';
const data = new Blob([new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f])], { type: 'application/octet-stream' });
saveAs(data, 'binaryFile.bin');
js-file-download is a simple package for downloading files on the client-side. It is similar to file-saver but with a simpler API and fewer features. It does not provide the same level of control over file types and options.
downloadjs is a utility that triggers a file download on the client-side. It is similar to file-saver but supports additional features like downloading data URLs and canvas elements directly. It also does not require Blob objects for file data.
npm install --save @types/file-saver
This package contains type definitions for FileSaver.js (https://github.com/eligrey/FileSaver.js/).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/file-saver.
// Type definitions for FileSaver.js 2.0
// Project: https://github.com/eligrey/FileSaver.js/
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
// Daniel Roth <https://github.com/DaIgeb>
// HitkoDev <https://github.com/HitkoDev>
// JounQin <https://github.com/JounQin>
// BendingBender <https://github.com/bendingbender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = FileSaver;
export as namespace saveAs;
/**
* FileSaver.js implements the saveAs() FileSaver interface in browsers that do not natively support it.
* @param data - The actual file data blob or URL.
* @param filename - The optional name of the file to be downloaded. If omitted, the name used in the file data will be used. If none is provided "download" will be used.
* @param options - Optional FileSaver.js config
*/
declare function FileSaver(data: Blob | string, filename?: string, options?: FileSaver.FileSaverOptions): void;
/**
* FileSaver.js implements the saveAs() FileSaver interface in browsers that do not natively support it.
* @param data - The actual file data blob or URL.
* @param filename - The optional name of the file to be downloaded. If omitted, the name used in the file data will be used. If none is provided "download" will be used.
* @param disableAutoBOM - Optional & defaults to `true`. Set to `false` if you want FileSaver.js to automatically provide Unicode text encoding hints
* @deprecated use `{ autoBom: false }` as the third argument
*/
// tslint:disable-next-line:unified-signatures
declare function FileSaver(data: Blob | string, filename?: string, disableAutoBOM?: boolean): void;
declare namespace FileSaver {
interface FileSaverOptions {
/**
* Automatically provide Unicode text encoding hints
* @default false
*/
autoBom: boolean;
}
const saveAs: typeof FileSaver;
}
saveAs
These definitions were written by Cyril Schumacher, Daniel Roth, HitkoDev, JounQin, and BendingBender.
FAQs
TypeScript definitions for file-saver
The npm package @types/file-saver receives a total of 1,194,234 weekly downloads. As such, @types/file-saver popularity was classified as popular.
We found that @types/file-saver demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.