mlh-javascript
v0.2.1
Published
This is a node packages that shares common javascript behaviors accross various NLH websites.
Readme
mlh-javascript
This is a node packages that shares common javascript behaviors accross various NLH websites.
Instalation and Usage
- Install the package wuth
npm i --save mlh-javascript - Import code into your javascript file by including the following line on top of your file
import MLH from 'mlh-javascript'; - You can use any functions inside MLHAuth module by calling them agains MLHAuth object. Like so:
import MLH from 'mlh-javascript';
MLH.auth.login( function(user) {
// do something with user
})Development
- Clone the repository
git clone https://github.com/MLH/mlh-javascript.git - Change into the directory
cd mlh-javascriptand install dependencies withnpm i - Start a development server with
npm start - In the root of the project there's an index html file, it's for development only, In case you need to add any triggers to test code(buttons, links etc.).
- For creating separate modules make a new file in the
jsfolder, for examplevalidateInput.js. Write some functions in it, for example
function validateEmail(email) {
// do something
}
function validatePassword(password) {
// do something
}
export default {
validateEmail,
validatePassword
}- Import the module in the
index.jsfileimport validations from './js/validateInput, and add it to the exports at the bottom of the file.
export default {
auth,
validations
};- Add, commit, merge, update version of the package to reflect changes you made with
npm version <newversion>,<newversion>should be a valid semver string, for example '2.3.1'. - Publish to npm with
npm publish
