diff --git a/.gitignore b/.gitignore index ccb2c80..3a06dfb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,16 @@ node_modules/ -package-lock.json \ No newline at end of file + +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# rollup +.rpt2_cache + +# Editor directories and files +.idea +.vscode +*.suo +*.ntvs* +*.njsproj +*.sln diff --git a/README.md b/README.md index 1647139..a27933e 100644 --- a/README.md +++ b/README.md @@ -8,19 +8,22 @@ npm install hotstuff ``` ## Usage -The preferred method of pulling HotStuff into your project is using NPM and a CommonJS module system. +The preferred method of pulling HotStuff into your project is using NPM. You can use either the CommonJS `require` or module `import` syntax. ```javascript const HotStuff = require('hotstuff') +// or +import HotStuff from 'hotstuff' ``` + You can then create a new HotStuff object using one of the methods below. -Note: HotStuff attaches events using addEventListener on both the keydown and keyup events so the object you pass to HotStuff must support those events. +Note: HotStuff attaches events using addEventListener on both the keydown and keyup events so the object you pass to HotStuff must support those events. ```javascript const element = document.getElementById('elem') const hotStuff = new HotStuff(element) -// You can also attach to the window +// You can also attach to the window const hotStuff = new HotStuff(window) // by default HotStuff attaches itself to the window object if there is one const hotStuff = new HotStuff() diff --git a/build/rollup.js b/build/rollup.js new file mode 100644 index 0000000..75aada2 --- /dev/null +++ b/build/rollup.js @@ -0,0 +1,83 @@ +/* eslint-disable */ + +// npm install rollup-plugin-typescript2 typescript --save-dev +import typescript from 'rollup-plugin-typescript2' +import { terser } from 'rollup-plugin-terser' +// import resolve from 'rollup-plugin-node-resolve' + +// ------------------------------------------------------------------------------------------ +// formats +// ------------------------------------------------------------------------------------------ +// amd – Asynchronous Module Definition, used with module loaders like RequireJS +// cjs – CommonJS, suitable for Node and Browserify/Webpack +// esm – Keep the bundle as an ES module file +// iife – A self-executing function, suitable for inclusion as a