npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mushroomjs-file

v1.2.0

Published

Extension File for mushroomjs

Downloads

47

Readme

Install

npm install mushroomjs-file

Or

yarn add mushroomjs-file

Dependent on

mushroomjs

Import

import mushroom from "mushroomjs-file";

Or

    import mushroom from "mushroomjs";
    import "mushroomjs-file";

Usage

Upload file

// upload binary file
let result = await mushroom.$file.uploadAsync({
    file: document.getElementById("fileUpload").files[0], // required
    name: "Name of file with extension", // optional
    tags: [ "tag1", "tag2" ], // optional
    contentFormat: "BINARY", // optional, default: BINARY
    progress: () => { /* Handle progress event */ } // optional
});

// upload BASE64 file
let result = await mushroom.$file.uploadAsync({
    file: document.getElementById("txtBase64").value, // required
    name: "Name of file with extension", // required
    tags: [ "tag1", "tag2" ], // optional
    contentFormat: "BASE64", // required
    progress: () => { /* Handle progress event */ } // optional
});

// upload a FormData
let formData = new FormData();
formData.append("file", value, "Name of file with extension"); // value can be a String or Blob
let result = await mushroom.$file.uploadAsync({
    file: formData, // required
    name: "Name of file with extension", // required
    tags: [ "tag1", "tag2" ], // optional
    contentFormat: "FORMDATA", // required
    progress: () => { /* Handle progress event */ } // optional
});

Download file

Support in web browser only

// download single file
mushroom.$file.download(fileId);

// download multiple files
mushroom.$file.zip([fileId1, fileId2]);

Make file link

let fileLink = mushroom.$file.linkBuilder.download.id(fileId).build();
let zipLink = mushroom.$file.linkBuilder.zip.add(fileId1).add([fileId2, fileId3]).build();

// or shortcut
let fileLink = mushroom.$file.getDownloadLink(fileId);
let zipLink = mushroom.$file.getZipLink([fileId1, fileId2, fileId3]);

Inline mode

let fileLink = mushroom.$file.linkBuilder.download.id(fileId).inline().build();

Make image thumbnail link

let imgSrc = mushroom.$file.linkBuilder.thumb
    .id(fileId) // required
    // .stretch(width: number, height: number)
    // .square(size: number)
    // .zoom(width: number, height: number, backgroundColor?) // backgroundColor: optional, default: transparent, valid values: transparent | [0-9a-fA-F]{6}
    // .x(width: number)
    // .y(height: number)
    .clip(150, 75, ImageVerticalAlign.TOP, ImageHorizontalAlign.LEFT) 
    // .clip(width: number, height: number, va?: ImageVerticalAlign, ha?: ImageHorizontalAlign)
    // .addEffect(effect)
    .rotate90()
    // .rotate180()
    // .rotate270()
    .flipVertical()
    // .flipHorizontal()
    .transparent(50) // value: from 0 to 255
    .grayscale()
    .allowSmallerSize()
    // .allowSmallerSize(allow: boolean)
    .format(ImageOutputFormat.PNG) // ImageOutputFormat: SOURCE, JPG, PNG, GIF, WEBP, AUTO
    .build();

Release notes

1.2.0

New features:

1.1.0

New features: