1.0.0 • Published 3 years ago

meme3 v1.0.0

Weekly downloads
-
License
LGPL-3.0
Repository
github
Last release
3 years ago

meme3.js - Popcateum JavaScript API

NPM Package Version NPM Package Downloads

This is the Popcateum JavaScript API which connects to the Generic JSON-RPC spec.

Please read the documentation for more.

Installation

Node

npm install meme3

Yarn

yarn add meme3

In the Browser

Use the prebuilt dist/meme3.min.js, or build using the meme3.js repository:

npm run build

Then include dist/meme3.min.js in your html file. This will expose Meme3 on the window object.

Usage

// In Node.js
const Meme3 = require('meme3');

let meme3 = new Meme3('ws://localhost:9507');
console.log(meme3);
> {
    pop: ... ,
    shh: ... ,
    utils: ...,
    ...
}

Additionally you can set a provider using meme3.setProvider() (e.g. WebsocketProvider):

meme3.setProvider('ws://localhost:9507');
// or
meme3.setProvider(new Meme3.providers.WebsocketProvider('ws://localhost:9507'));

There you go, now you can use it:

meme3.pop.getAccounts().then(console.log);

Usage with TypeScript

We support types within the repo itself. Please open an issue here if you find any wrong types.

You can use meme3.js as follows:

import Meme3 from 'meme3';
const meme3 = new Meme3('ws://localhost:9507');

If you are using the types in a commonjs module, like in a Node app, you just have to enable esModuleInterop and allowSyntheticDefaultImports in your tsconfig for typesystem compatibility:

"compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    ....

Trouble shooting and known issues.

Meme3 and Angular

If you are using Ionic/Angular at a version >5 you may run into a build error in which modules crypto and stream are undefined

a work around for this is to go into your node-modules and at /angular-cli-files/models/webpack-configs/browser.js change the node: false to node: {crypto: true, stream: true} as mentioned here

Another variation of this problem was an issue opned on angular-cli: https://github.com/angular/angular-cli/issues/1548

Documentation

Documentation can be found at ReadTheDocs.

Building

Requirements

sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm

Building (webpack)

Build the meme3.js package:

npm run build

Testing (mocha)

npm test

Contributing

Please follow the Contribution Guidelines and Review Guidelines.

This project adheres to the Release Guidelines.

Community

Similar libraries in other languages

Semantic versioning

This project follows semver as closely as possible from version 1.3.0 onwards. Earlier minor version bumps might have included breaking behavior changes.