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 🙏

© 2026 – Pkg Stats / Ryan Hefner

megajs-2

v0.0.4

Published

Unofficial JavaScript SDK for MEGA

Readme

MEGAJS 2

Unofficial JavaScript SDK for MEGA

  • As the original MEGAJS is no longer maintained, I created MEGAJS 2 to fix issues I have encountered.
  • This is based on tonistiigi's mega library.
  • This is all unofficial, based on developer guide and site source.
  • Make sure you agree with MEGA's Terms of Service before using it.
  • Maybe an official SDK will probably be released in the future here: https://github.com/meganz/

Installation

npm install megajs-2
const mega = require('megajs-2') // or
import mega from 'megajs-2'

You can also load it in a browser using <script src="https://unpkg.com/megajs/dist/main.node-cjs.js"></script>, which exports the library in the mega global variable. You can also use import * as mega from 'https://unpkg.com/megajs/dist/main.browser-es.js'.

For more details, API documentation and examples check wiki: https://github.com/qgustavor/mega/wiki

The bundled files are available via npm and UNPKG.

For CLI usage check MEGAJS CLI: https://github.com/qgustavor/megajs-cli

Implementation notes

Only part of the file related API is implemented. For now implementing contact and chat functions seems out of scope.

Cryptography is mostly ported from browser code. In Node some parts are optimized: AES operations are done using native crypto. Sadly WebCrypto don't support streaming so in browser the old pure JavaScript implementation is used. The RSA operations aren't optimized as currently there isn't any need to improve that.

This module works in the browser: the "main.browser-umd.js" is a build using the UMD format where Node specific modules, like crypto and request modules, were replaced with browser equivalents. If you want to use tree shaking then use the "main.browser-es.js" bundle. This module wasn't tested in other environments.

Fork objectives

This package started as a fork, with the following objectives:

  • Make the original package work in browsers again: even following the instructions from the original library it stopped working because some dependencies used __proto__, which is non-standard and isn't supported in many browsers. Also the updated versions of those libraries broke backyards compatibility;
  • Reduce dependencies and replace big dependencies with smaller ones, like crypto libraries, which usually are huge;
  • Rewrite code using the new JavaScript syntax, allowing to use Rollup, which can generate smaller bundles;
  • Make tests work again after the changes above;
  • Continue the original library development implementing new features and improving performance.

Request package was replaced with a shim based in browser-request and xhr-stream, which additional changes in order to make it work inside Service Workers. Crypto was replaced with secure-random.

As there were many changes there isn't any plan to merge those changes into the original library, unless the original author accept those massive changes. That's why I put "js" in the name, which is silly because both libraries use JavaScript. At least it's better than other ideas I had, like "mega2", "mega-es" and "modern-mega".

Contributing

When contributing fork the project, clone it, run npm install, change the library as you want, run tests using npm run test and build the bundled versions using npm run build. Before creating a pull request, please, run tests.