/dummy_calcul

for experimenting ts-written npm package for nodejs and browser

Primary LanguageJavaScript

README of dummy_calcul

Presentation

The repository dummy_calcul is for learning and experimenting a TS-written NPM package for use in Node-JS or Browser. It is inspired by this blog-post

The goal of this library is to learn publishing a npm-package for nodejs and browser.

Project links

Getting started

for NodeJS

In a bash-terminal:

mkdir test
cd test
npm i dummy-calcul

In a nodejs-script:

const dummyCalcul = require("dummy-calcul");
let result = dummyCalcul.add1000(9);
console.log(result);

for NodeJS with TypeScript

In a bash-terminal:

mkdir test
cd test
npm i dummy-calcul typescript

In a ts-script, called abc.ts:

import { add1000, mult1000 } from "dummy-calcul";
console.log(add1000(5));
console.log(mult1000(7));

In a bash-terminal:

npx tsc abc.ts
node abc.js

for browser

In your html-file:

<script src="https://unpkg.com/dummy-calcul@1.2.0/dist/dummy-calcul.min.js"></script>

Using the CLI

In a bash-terminal:

mkdir test
cd test
npm i dummy-calcul
npx dummy-calcul-cli add1000 -n 7
npx dummy-calcul-cli mult1000 -n 8

Publish an update

In a bash-terminal:

git commit -am "some updates"
npm version minor
git push
npm publish