rjutils-collection
Advanced tools
Comparing version 1.5.3 to 1.6.0
@@ -41,2 +41,3 @@ "use strict"; | ||
randomBol: () => randomBol, | ||
randomCode: () => randomCode, | ||
randomNum: () => randomNum, | ||
@@ -48,4 +49,4 @@ randomStr: () => randomStr, | ||
module.exports = __toCommonJS(src_exports); | ||
var path = __toESM(require("path")); | ||
var fs = __toESM(require("fs")); | ||
var import_path = __toESM(require("path")); | ||
var import_fs = __toESM(require("fs")); | ||
var import_size = __toESM(require("./functions/size")); | ||
@@ -60,3 +61,3 @@ var import_time = __toESM(require("./functions/time")); | ||
throw new TypeError("filePath must be a string"); | ||
const resolvedFile = path.resolve(file); | ||
const resolvedFile = import_path.default.resolve(file); | ||
const parseContent = (content) => { | ||
@@ -73,3 +74,3 @@ let returns = {}; | ||
try { | ||
const content = await fs.promises.readFile(resolvedFile, "utf8"); | ||
const content = await import_fs.default.promises.readFile(resolvedFile, "utf8"); | ||
return resolve(parseContent(content)); | ||
@@ -81,3 +82,3 @@ } catch (err) { | ||
else | ||
return parseContent(fs.readFileSync(resolvedFile, "utf8")); | ||
return parseContent(import_fs.default.readFileSync(resolvedFile, "utf8")); | ||
} | ||
@@ -118,2 +119,15 @@ function randomNum(min, max, dec) { | ||
} | ||
function randomCode(segments, options = {}) { | ||
if (!Array.isArray(segments)) | ||
throw new TypeError("segments must be an array"); | ||
if (typeof options !== "object") | ||
throw new TypeError("options must be an object"); | ||
let result = ""; | ||
for (let i = 0; i < segments.length; i++) { | ||
result += randomStr({ ...options, length: segments[i] }).replace(/-/g, "."); | ||
if (i !== segments.length - 1) | ||
result += "-"; | ||
} | ||
return result; | ||
} | ||
class Spinner { | ||
@@ -229,7 +243,7 @@ /** Create a Spinner */ | ||
const output = []; | ||
for (const file of await fs.promises.readdir(directory2, { withFileTypes: true })) { | ||
for (const file of await import_fs.default.promises.readdir(directory2, { withFileTypes: true })) { | ||
if (file.isDirectory()) | ||
output.push(...await handleDirectory(path.join(directory2, file.name))); | ||
output.push(...await handleDirectory(import_path.default.join(directory2, file.name))); | ||
else | ||
output.push(path.join(directory2, file.name)); | ||
output.push(import_path.default.join(directory2, file.name)); | ||
} | ||
@@ -247,7 +261,7 @@ return output; | ||
const output = []; | ||
for (const file of fs.readdirSync(directory2, { withFileTypes: true })) { | ||
for (const file of import_fs.default.readdirSync(directory2, { withFileTypes: true })) { | ||
if (file.isDirectory()) | ||
output.push(...handleDirectory(path.join(directory2, file.name))); | ||
output.push(...handleDirectory(import_path.default.join(directory2, file.name))); | ||
else | ||
output.push(path.join(directory2, file.name)); | ||
output.push(import_path.default.join(directory2, file.name)); | ||
} | ||
@@ -271,2 +285,3 @@ return output; | ||
randomBol, | ||
randomCode, | ||
randomNum, | ||
@@ -273,0 +288,0 @@ randomStr, |
{ | ||
"name": "rjutils-collection", | ||
"version": "1.5.3", | ||
"version": "1.6.0", | ||
"description": "Easy and Lightweight Utilities", | ||
@@ -5,0 +5,0 @@ "module": "lib/esm/index.js", |
@@ -1,3 +0,3 @@ | ||
import * as path from "path"; | ||
import * as fs from "fs"; | ||
import path from "path"; | ||
import fs from "fs"; | ||
import { default as default2 } from "./functions/size"; | ||
@@ -67,2 +67,15 @@ import { default as default3 } from "./functions/time"; | ||
} | ||
function randomCode(segments, options = {}) { | ||
if (!Array.isArray(segments)) | ||
throw new TypeError("segments must be an array"); | ||
if (typeof options !== "object") | ||
throw new TypeError("options must be an object"); | ||
let result = ""; | ||
for (let i = 0; i < segments.length; i++) { | ||
result += randomStr({ ...options, length: segments[i] }).replace(/-/g, "."); | ||
if (i !== segments.length - 1) | ||
result += "-"; | ||
} | ||
return result; | ||
} | ||
class Spinner { | ||
@@ -217,2 +230,3 @@ /** Create a Spinner */ | ||
randomBol, | ||
randomCode, | ||
randomNum, | ||
@@ -219,0 +233,0 @@ randomStr, |
{ | ||
"name": "rjutils-collection", | ||
"version": "1.5.3", | ||
"version": "1.6.0", | ||
"description": "Easy and Lightweight Utilities", | ||
@@ -5,0 +5,0 @@ "module": "lib/esm/index.js", |
@@ -18,4 +18,4 @@ /// <reference types="node" /> | ||
* @since 1.0.0 | ||
*/ export declare function loadEnv<File extends string, Async extends boolean | undefined>( | ||
/** The path to the Env file */ file: File, | ||
*/ export declare function loadEnv<Async extends boolean | undefined>( | ||
/** The path to the Env file */ file: string, | ||
/** Whether to load the File Async */ isAsync?: Async): Async extends true ? Promise<Record<string, string>> : Record<string, string>; | ||
@@ -41,2 +41,14 @@ /** | ||
/** | ||
* Generate a Random Code | ||
* | ||
* When `symbols` is enabled, generated `-` will be replaced with `.` | ||
* @example | ||
* ``` | ||
* randomCode([1, 2]) // O-kN | ||
* randomCode([6, 7]) // QyzKcJ-vUveJHR | ||
* randomCode([3, 4], { symbols: true }) // ~?&-LDbe | ||
* ``` | ||
* @since 1.6.0 | ||
*/ export declare function randomCode(segments: number[], options?: Omit<randomStrOptions, 'length'>): string; | ||
/** | ||
* Generate a Text Spinner | ||
@@ -43,0 +55,0 @@ * @since 1.0.2 |
{ | ||
"name": "rjutils-collection", | ||
"version": "1.5.3", | ||
"version": "1.6.0", | ||
"description": "Easy and Lightweight Utilities", | ||
@@ -5,0 +5,0 @@ "module": "lib/esm/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52450
1551