qsu 0.5.4 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -9
- package/format.js +6 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -125,15 +125,15 @@ Utility for data inspection.
|
|
|
125
125
|
## qsu.format
|
|
126
126
|
Utility that converts to Human-Readable String format.
|
|
127
127
|
|
|
128
|
-
| Method | Params
|
|
129
|
-
| ---
|
|
130
|
-
| .number | val **{String|Number}**
|
|
131
|
-
| .fileName | <li>filePath **{String}**</li><li>withExtension **{Boolean}**</li>
|
|
132
|
-
| .fileSize | <li>bytes **{Number}**</li><li>decimals **{Number}**</li>
|
|
133
|
-
| .fileExt | <li>filePath **{String}**</li>
|
|
134
|
-
| .msToTime | <li>milliseconds **{Number}**</li><li>withMilliseconds **{Boolean}**</li><li>separator **{String}**</li>
|
|
135
|
-
| .secToTime | <li>seconds **{Number}**</li><li>separator **{String}**</li><li>onlyHour **{Boolean}**</li>
|
|
136
|
-
| .license | <li>type(Required, Currently
|
|
128
|
+
| Method | Params | Description | Example |
|
|
129
|
+
| --- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| --- | --- |
|
|
130
|
+
| .number | val **{String|Number}** | Return in number format including comma symbol. | `number(1234567) // 1,234,567` |
|
|
131
|
+
| .fileName | <li>filePath **{String}**</li><li>withExtension **{Boolean}**</li> | Extract the file name from the path. Include the extension if withExtension is true. | `fileName('C:\Temp\hello.txt') // 'hello.txt'`<br/>`fileName('C:\Temp\file.mp3', true) // 'file.mp3'` |
|
|
132
|
+
| .fileSize | <li>bytes **{Number}**</li><li>decimals **{Number}**</li> | Converts the file size in bytes to human-readable and returns it. The return value is a String and includes the file units (Bytes, MB, GB...). If the second optional argument value is included, you can display as many decimal places as you like. | `fileSize(2000, 3) // '1.953 KB'`<br/>`fileSize(250000000) // '238.42 MB'` |
|
|
133
|
+
| .fileExt | <li>filePath **{String}**</li> | Returns only the extensions in the file path. If unknown, returns 'Unknown'. | `fileExt('C:\Temp\hello.txt') // 'txt'`<br/>`fileExt('this-is-file.mp3') // 'mp3'` |
|
|
134
|
+
| .msToTime | <li>milliseconds **{Number}**</li><li>withMilliseconds **{Boolean}**</li><li>separator **{String}**</li> | Converts milliseconds to hours, minutes, seconds, and milliseconds and returns. If the second argument is true, milliseconds are also printed. You can put any separator (String) between hours, minutes, and seconds in the third argument. | `msToTime(100000) // '00:01:40'`<br/>`msToTime(100000, true, '-') // '00-01-40.0'` |
|
|
135
|
+
| .secToTime | <li>seconds **{Number}**</li><li>separator **{String}**</li><li>onlyHour **{Boolean}**</li> | Converts seconds to hours, minutes, seconds and returns. You can put any separator (String) between hours, minutes, and seconds in the third argument. | `secToTime(3800) // '01:03:20'`<br/>`secToTime(60, '-') // '00-01-00'` |
|
|
136
|
+
| .license | <li>type(Required, Currently 'apache20', 'mit' is supported) **{String}**</li><li>author(Required) **{String}**</li><li>yearStart(Required) **{String}**</li><li>yearEnd **{String}**</li><li>email **{string}**</li><li>htmlBr **{string}**</li> | Returns text in a specific license format based on the author information of the given argument. The argument uses the Object type. | `license({ holder: 'example', email: 'example@example.com', yearStart: 2020, yearEnd: 2021, htmlBr: true })` |
|
|
137
137
|
|
|
138
138
|
## qsu.date
|
|
139
139
|
Utility to simplify date format printing or calculation.
|
package/format.js
CHANGED
|
@@ -57,11 +57,15 @@ const license = (args = {}) => {
|
|
|
57
57
|
throw new Error('holder and startYear are required.');
|
|
58
58
|
}
|
|
59
59
|
const br = args.htmlBr ? '<br/>' : '\n';
|
|
60
|
-
const type = args?.type?.toLowerCase() || 'mit';
|
|
60
|
+
const type = args?.type?.replace(/\./g, '').toLowerCase() || 'mit';
|
|
61
|
+
const yearString = `${args.yearStart}${args.yearEnd ? `-${args.yearEnd}` : ''}`;
|
|
62
|
+
const authorString = `${args.author}${args.email ? ` <${args.email}>` : ''}`;
|
|
61
63
|
switch (type) {
|
|
64
|
+
case 'apache20':
|
|
65
|
+
return `Copyright ${yearString} ${authorString}${br}${br}Licensed under the Apache License, Version 2.0 (the "License");${br}you may not use this file except in compliance with the License.${br}You may obtain a copy of the License at${br}${br} http://www.apache.org/licenses/LICENSE-2.0${br}${br}Unless required by applicable law or agreed to in writing, software${br}distributed under the License is distributed on an "AS IS" BASIS,${br}WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.${br}See the License for the specific language governing permissions and${br}limitations under the License.`;
|
|
62
66
|
case 'mit':
|
|
63
67
|
default:
|
|
64
|
-
return `Copyright (c) ${
|
|
68
|
+
return `Copyright (c) ${yearString} ${authorString}${br}${br}Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:${br}${br}The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.${br}${br}THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.`;
|
|
65
69
|
}
|
|
66
70
|
};
|
|
67
71
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qsu",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "Quick and Simple Utility for javascript",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "npm run lint && mocha --require @babel/register --parallel test/*.spec.js",
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"@babel/node": "^7.16.8",
|
|
28
28
|
"@babel/preset-env": "^7.16.11",
|
|
29
29
|
"@babel/register": "^7.17.7",
|
|
30
|
-
"eslint": "^8.
|
|
30
|
+
"eslint": "^8.13.0",
|
|
31
31
|
"eslint-config-airbnb": "^19.0.4",
|
|
32
|
-
"eslint-plugin-import": "^2.
|
|
32
|
+
"eslint-plugin-import": "^2.26.0",
|
|
33
33
|
"mocha": "^9.2.2"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"moment": "^2.29.
|
|
36
|
+
"moment": "^2.29.2"
|
|
37
37
|
}
|
|
38
38
|
}
|