A library with common function implementations for Javascript Applications.
If your application uses some module bundler, you can import the whole Commons-js library, a single module, or just a single function, making your source code smaller because only the features you need will be concatened to your build application.
The examples below were tested using Webpack, if you use another module bundler things might not work as well as expected.
Import the whole library and use it on your app:
import { commons } from '@linx-impulse/commons-js';
// make an ajax request
commons.http.ajax({
url: 'http://www.google.com',
callback: () => {
console.log('OK');
}
});
Import just the Http
module. Only the implementation of this module functions will be bundled to your application source code.
import { http } from '@linx-impulse/commons-js/http';
// make an ajax request
http.ajax({
url: 'http://www.google.com',
callback: () => {
console.log('OK');
}
});
Import just the ajax
function. Only the implementation of this function will be bundled to your application source code.
import { ajax } from '@linx-impulse/commons-js/http/ajax';
// make an ajax request
ajax({
url: 'http://www.google.com',
callback: () => {
console.log('OK');
}
});
The Commons always exports the main module/function as default export of a file, so if your application uses CommonJS
syntax, you can require the default module of each file.
Examples:
Require the whole library and use it on your app:
const commons = require('@linx-impulse/commons-js');
// make an ajax request
commons.http.ajax({
url: 'http://www.google.com',
callback: () => {
console.log('OK');
}
});
Require just the Http
module. Only the implementation of this module functions will be bundled to your application source code.
const http = require('@linx-impulse/commons-js/http');
// make an ajax request
http.ajax({
url: 'http://www.google.com',
callback: () => {
console.log('OK');
}
});
Require just the ajax
function. Only the implementation of this function will be bundled to your application source code.
const ajax = require('@linx-impulse/commons-js/http/ajax');
// make an ajax request
ajax({
url: 'http://www.google.com',
callback: () => {
console.log('OK');
}
});
We follow Airbnb JavaScript Style Guide and use eslint to validate the code. Before push a commit please run npm run lint
to validate your code.
We have very precise rules over how our git commit messages can be formatted. This leads to more readable messages that are easy to follow when looking through the project history. But also, we use the git commit messages to generate our change log.
The Commit Message Guidelines are documented here: https://share.linx.com.br/x/0txLAg.