qsu 1.0.7 → 1.0.8

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/.eslintrc.cjs CHANGED
@@ -16,7 +16,7 @@ module.exports = {
16
16
  'plugin:@typescript-eslint/recommended',
17
17
  ],
18
18
  rules: {
19
- 'linebreak-style': ['error', 'windows'],
19
+ 'linebreak-style': 0,
20
20
  'arrow-parens': 0,
21
21
  'max-len': 0,
22
22
  '@typescript-eslint/no-explicit-any': 0
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { basename, extname } from 'path';
1
+ import { basename, extname, win32 } from 'path';
2
2
  import { randomBytes, createCipheriv, createDecipheriv, createHash, } from 'crypto';
3
3
  export default class Qsu {
4
4
  /*
@@ -177,6 +177,9 @@ export default class Qsu {
177
177
  }
178
178
  static truncate(str, length, ellipsis = '') {
179
179
  let convStr = str;
180
+ if (!str) {
181
+ return '';
182
+ }
180
183
  if (str.length > length) {
181
184
  convStr = str.substring(0, length) + ellipsis;
182
185
  }
@@ -361,6 +364,16 @@ export default class Qsu {
361
364
  return new Intl.NumberFormat().format(number);
362
365
  }
363
366
  static fileName(filePath, withExtension = false) {
367
+ if (!filePath) {
368
+ return '';
369
+ }
370
+ if (filePath.indexOf('/') === -1) {
371
+ // Windows path
372
+ if (withExtension) {
373
+ return win32.basename(filePath);
374
+ }
375
+ return win32.basename(filePath, extname(filePath));
376
+ }
364
377
  if (withExtension) {
365
378
  return basename(filePath);
366
379
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "qsu",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Quick and Simple Utility for JavaScript",
5
5
  "type": "module",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
- "test": "npm run lint && npm run build && mocha --parallel test/*.spec.js",
9
+ "test": "npm run build && mocha --parallel test/*.spec.js",
10
10
  "lint": "eslint .",
11
11
  "lint:fix": "eslint --fix ."
12
12
  },
@@ -43,11 +43,11 @@
43
43
  "math"
44
44
  ],
45
45
  "devDependencies": {
46
- "@types/node": "^18.0.6",
47
- "@typescript-eslint/eslint-plugin": "^5.30.7",
48
- "@typescript-eslint/parser": "^5.30.7",
46
+ "@types/node": "^18.7.3",
47
+ "@typescript-eslint/eslint-plugin": "^5.33.0",
48
+ "@typescript-eslint/parser": "^5.33.0",
49
49
  "date-fns": "^2.29.1",
50
- "eslint": "^8.20.0",
50
+ "eslint": "^8.22.0",
51
51
  "eslint-config-airbnb": "^19.0.4",
52
52
  "eslint-plugin-import": "^2.26.0",
53
53
  "mocha": "^10.0.0",