Skip to content

Commit

Permalink
Merge branch 'main' into 96-test-all-function-and-the-code
Browse files Browse the repository at this point in the history
  • Loading branch information
201flaviosilva committed Nov 8, 2022
2 parents 34f2aca + 5b67e16 commit ce1b92c
Show file tree
Hide file tree
Showing 19 changed files with 161 additions and 55 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Export

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
export:
name: Build
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install Dependencies
run: npm ci

- name: Build
run: npm run compile

- name: Upload Artifact
uses: actions/upload-artifact@v1
with:
name: "201flaviosilva-utils"
path: build
31 changes: 22 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
This file was based on [this template](https://gist.github.com/juampynr/4c18214a8eb554084e21d6e288a18a2c).

----
## [1.3 - Tests and monorepo](https://github.com/201flaviosilva-labs/javascript-utils/milestone/4)

### [1.3.0] - 00-11-2022

#### Added

#### Changed

#### Fixed

#### Breaking Changes


## [1.2.0 - More Functions](https://github.com/201flaviosilva-labs/javascript-utils/milestone/2)

## [1.2.10] - 21-10-2022
### [1.2.10] - 21-10-2022

### Added
#### Added
- [Add some Sorting Algorithm](https://github.com/201flaviosilva-labs/javascript-utils/commit/5d248aa08a3f4de28843aa5c788bfe9cc55f9fda);
- [Array New Sort](https://github.com/201flaviosilva-labs/javascript-utils/commit/9260d39f2d567705d09aa0ee2b69fec2a429b3c2) - Return a new array sorted based in the given one;
- [Array Is Sorted](https://github.com/201flaviosilva-labs/javascript-utils/commit/9260d39f2d567705d09aa0ee2b69fec2a429b3c2) - Check if the array is sorted;
Expand All @@ -26,11 +39,11 @@ This file was based on [this template](https://gist.github.com/juampynr/4c18214a
- [getOSVersion](https://github.com/201flaviosilva-labs/javascript-utils/commit/c81f718f9497adc9f69f057950f7594b12dfa52d) - Returns the OS version #44;
- [isMobile](https://github.com/201flaviosilva-labs/javascript-utils/commit/c81f718f9497adc9f69f057950f7594b12dfa52d) - Check if is in a mobile device #44;

### Changed
#### Changed
- [Add more examples to the functions](https://github.com/201flaviosilva-labs/javascript-utils/commit/06c75f5b84da32b9af4521eab48afc3d4982a8aa);
- [`and` and `or` can receive infinity args](https://github.com/201flaviosilva-labs/javascript-utils/commit/2473d089c7a699650abfce108425ee0d479ce7e7) #88;

### Fixed
#### Fixed

#### Breaking Changes
- Move project from GitLab to GitHub;
Expand All @@ -43,19 +56,19 @@ This file was based on [this template](https://gist.github.com/juampynr/4c18214a
- [Removed Games](https://github.com/201flaviosilva-labs/javascript-utils/commit/40367810b608d5271f2795df44ec4e7dea02fd29);


## [1.2.9] - 02-09-2022
### [1.2.9] - 02-09-2022

### Added
#### Added
- [Random Walk](https://github.com/201flaviosilva-labs/javascript-utils/commit/56eebcaac033c05401140c4418b54e9579fb8d38) #46;
- [Binary Search Tree](https://github.com/201flaviosilva-labs/javascript-utils/commit/b141db4e7a0089a7c99a9ca8a70f7a37f73d59ef) #11;

### Changed
#### Changed
- ["Skip" zones in range](https://github.com/201flaviosilva-labs/javascript-utils/commit/b0d7a1d585f194c093ba22f621ebf71a0d5ce793) #68;

### Fixed
#### Fixed
- [Median](https://github.com/201flaviosilva-labs/javascript-utils/commit/bb9e8d4aba6f64cc6752b7f0853460c2edc03d74);

### Breaking Changes
#### Breaking Changes
- `findBigArrObj` and `getMaxArrayObjects` change to `arrayFindBigObject` #74;
- `findLowArrObj` and `getMinArrayObjects` change to `arrayFindLowObject` #74;
- `sortAscending` change to `arraySortAscending` #74;
Expand Down
2 changes: 1 addition & 1 deletion build/utils.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
"test:all": "jest",
"jsDoc": "jsdoc -c jsdoc.conf.json",
"types": "npx -p typescript tsc src/*.js --declaration --allowJs --emitDeclarationOnly --outDir types",
"compile": "webpack --mode production",
"compile": "npm run compile:browser && npm run compile:node && npm run compile:css",
"compile:browser": "webpack --mode production --config ./scripts/webpack-browser.config.js",
"compile:node": "webpack --mode production --config ./scripts/webpack-node.config.js",
"compile:css": "css-minify -d src/CSSFreeStyle/ -o build",
"build": "npm run clear && npm run compile && npm run compile:css && npm run jsDoc && npm run types",
"bump": "npm run build && np"
Expand Down
File renamed without changes.
23 changes: 23 additions & 0 deletions scripts/webpack-node.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const path = require("path");

module.exports = {
mode: "production",
entry: "./src/index.js",
optimization: { minimize: true, }, // false/true
experiments: { outputModule: true, },
output: {
path: path.resolve("build"),
filename: "utils.min.cjs", // "utils.js"/"utils.min.js"
libraryTarget: "commonjs2", // module/commonjs2/window // https://webpack.js.org/configuration/output/#outputlibrarytarget
},
module: {
rules: [
{
test: /\.js?$/,
exclude: /(node_modules)/,
use: "babel-loader",
},
],
},
resolve: { extensions: [".js"], },
};
23 changes: 23 additions & 0 deletions scripts/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const path = require("path");

module.exports = {
mode: "production",
entry: "./src/index.js",
optimization: { minimize: true, }, // false/true
experiments: { outputModule: true, },
output: {
path: path.resolve("build"),
filename: "utils.min.js", // "utils.js"/"utils.min.js"
libraryTarget: "commonjs2", // module/commonjs2/window // https://webpack.js.org/configuration/output/#outputlibrarytarget
},
module: {
rules: [
{
test: /\.js?$/,
exclude: /(node_modules)/,
use: "babel-loader",
},
],
},
resolve: { extensions: [".js"], },
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions src/Device/index.js → src/DOM/Device/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { getBrowser } from "./getBrowser.js";
import { getBrowserVersion } from "./getBrowserVersion.js";
import { getDate, getTime, getMilliseconds, getSeconds, getMinutes, getHours, getDay, getWeekDay, getWeek, getMonth, getYear, getDateFormatted } from "./getDate.js";
import { getOS } from "./getOS.js";
import { getOSVersion } from "./getOSVersion.js";
import { isMobile } from "./isMobile.js";

/**
* Detects the user/OS/Browser info
*
* @memberof DOM
* @namespace Device
*/
export {
getBrowser,
getBrowserVersion,
getDate, getTime, getMilliseconds, getSeconds, getMinutes, getHours, getDay, getWeekDay, getWeek, getMonth, getYear, getDateFormatted,
getOS,
getOSVersion,
isMobile,
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions src/DOM/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as Device from "./Device/index.js";
import { deleteAllChildDom } from "./deleteAllChildDom.js";
import { exportFile } from "./exportFile.js";
import { getUrlParameter } from "./getUrlParameter.js";
Expand All @@ -12,6 +13,8 @@ import { toggleFullScreen } from "./toggleFullScreen.js";
* @namespace DOM
*/
export {
Device,

deleteAllChildDom,
exportFile,
getUrlParameter,
Expand Down
18 changes: 18 additions & 0 deletions src/choiceTrend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function choiceTrend(options = [0.25, 0.5, 0.25]) {
let sum = 0;
const trend = options.map(o => {
sum += o;
return sum;
});

console.log(trend);

const random = Math.random();
if (random <= trend[0]) {
console.log("0 -> ", random);
} else if (random <= trend[1]) {
console.log("1 -> ", random);
} else {
console.log("2 -> ", random);
}
}
36 changes: 0 additions & 36 deletions src/Device/getDate.js → src/getDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
}
*
* @returns {Object}
*
* @function getDate
* @memberof Device
*/
export function getDate() {
return {
Expand All @@ -46,9 +43,6 @@ export function getDate() {
* getTime() // 1653573577063
*
* @returns {number}
*
* @function getTime
* @memberof Device
*/
export function getTime() { return new Date().getTime(); }

Expand All @@ -61,9 +55,6 @@ export function getTime() { return new Date().getTime(); }
* getMilliseconds() // 952
*
* @returns {number} current milliseconds
*
* @function getMilliseconds
* @memberof Device
*/
export function getMilliseconds() { return new Date().getMilliseconds(); }

Expand All @@ -76,9 +67,6 @@ export function getMilliseconds() { return new Date().getMilliseconds(); }
* getSeconds() // 24
*
* @returns {number} current seconds
*
* @function getSeconds
* @memberof Device
*/
export function getSeconds() { return new Date().getSeconds(); }

Expand All @@ -91,9 +79,6 @@ export function getSeconds() { return new Date().getSeconds(); }
* getMinutes() // 24
*
* @returns {number} current minutes
*
* @function getMinutes
* @memberof Device
*/
export function getMinutes() { return new Date().getMinutes(); }

Expand All @@ -106,9 +91,6 @@ export function getMinutes() { return new Date().getMinutes(); }
* getHours() // 23
*
* @returns {number} current hours
*
* @function getHours
* @memberof Device
*/
export function getHours() { return new Date().getHours(); }

Expand All @@ -122,9 +104,6 @@ export function getHours() { return new Date().getHours(); }
* getDay() // 31
*
* @returns {number} current day
*
* @function getDay
* @memberof Device
*/
export function getDay() { return new Date().getDate(); }

Expand All @@ -138,9 +117,6 @@ export function getDay() { return new Date().getDate(); }
* getWeekDay() // 7
*
* @returns {number} current day of the week
*
* @function getWeekDay
* @memberof Device
*/
export function getWeekDay() { return new Date().getDay() + 1; }

Expand All @@ -152,9 +128,6 @@ export function getWeekDay() { return new Date().getDay() + 1; }
* getWeek() // 50
*
* @returns {number} current week in the year
*
* @function getWeek
* @memberof Device
*/
export function getWeek() {
const currentDate = new Date();
Expand All @@ -175,9 +148,6 @@ export function getWeek() {
* getDay() // 12
*
* @returns {number} current month
*
* @function getMonth
* @memberof Device
*/
export function getMonth() { return new Date().getMonth() + 1; }

Expand All @@ -191,9 +161,6 @@ export function getMonth() { return new Date().getMonth() + 1; }
* getDay() // 2042
*
* @returns {number} current year
*
* @function getYear
* @memberof Device
*/
export function getYear() { return new Date().getFullYear(); }

Expand All @@ -206,8 +173,5 @@ export function getYear() { return new Date().getFullYear(); }
* getDateFormatted() // "25/12/2042"
*
* @returns {string}
*
* @function getDateFormatted
* @memberof Device
*/
export function getDateFormatted() { return getDay() + "/" + getMonth() + "/" + getYear(); }
8 changes: 5 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as Array from "./Array/index.js";
import * as Device from "./Device/index.js";
import * as DOM from "./DOM/index.js";
import * as Maths from "./Maths/index.js";
import * as Physics from "./Physics/index.js";
Expand All @@ -8,9 +7,11 @@ import * as SortingAlgorithms from "./SortingAlgorithms/index.js";
import { allCharactersSame } from "./allCharactersSame.js";
import { binary2Decimal } from "./binary2Decimal.js";
import { BinarySearchTree, BinarySearchTreeInstance } from "./BinarySearchTree.js";
import { choiceTrend } from "./choiceTrend.js";
import { clone } from "./clone.js";
import { compare2Objects } from "./compare2Objects.js";
import { decimal2Binary } from "./decimal2Binary.js";
import { getDate } from "./getDate.js"; // getTime, getMilliseconds, getSeconds, getMinutes, getHours, getDay, getWeekDay, getWeek, getMonth, getYear, getDateFormatted
import { EventSystem, EventSystemInstance } from "./EventSystem.js";
import { Fibonacci, fibonacciSequence, fibonacciUntil, fibonacciCustomSequence, recursiveFibonacci } from "./Fibonacci.js";
import { getVersion } from "./getVersion.js";
Expand All @@ -26,7 +27,6 @@ import { Vector2 } from "./Vector2.js";

export {
Array,
Device,
DOM,
Maths,
Physics,
Expand All @@ -39,9 +39,11 @@ export {

allCharactersSame,
binary2Decimal,
clone,
compare2Objects,
decimal2Binary,
choiceTrend,
clone,
getDate,
getVersion,
isObjectEmpty,
isFalsy, isTruthy,
Expand Down
8 changes: 5 additions & 3 deletions wiki/Custom-Build.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ One way to do that it’s cloning the repository, opening a new terminal, and pa

(You need to have git installed on your machine)
```sh
git clone https://gitlab.com/201flaviosilva/utilsjs.git
git clone https://github.com/201flaviosilva-labs/javascript-utils.git
```

### Install the decencies
Expand All @@ -38,7 +38,9 @@ npm install

## Step 1 - webpack.config.js

In the file tree you'll find a `webpack.config.js` file, open and you will find a configuration more or less similar to the one below.
If you want you can open the project in any code editor, I recommend [VS Code](https://code.visualstudio.com/).

In the file tree you'll find a `scripts/webpack.config.js` file, open and you will find a configuration more or less similar to the one below.

```javascript
const path = require("path");
Expand Down Expand Up @@ -94,6 +96,6 @@ In the property `libraryTarget` you'll find the target of the library.

## Step 3 - Build

Finally, you'll need to run the command `npm run compile` in the terminal.
Finally, you'll need to run the command `webpack --mode production --config ./scripts/webpack.config.js` in the terminal.

Check your folder tree, and in the folder build you'll find the file build file with the name of the file you've changed in the configuration.

0 comments on commit ce1b92c

Please sign in to comment.