Compare commits
6
Commits
v9.41.3
...
c38ff8b405
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c38ff8b405 | ||
|
|
66d5f6247b | ||
|
|
74da813832 | ||
|
|
e2362418aa | ||
|
|
71e34848d9 | ||
|
|
f275180571 |
No files matched your search
@@ -124,3 +124,11 @@ The development for those files is located in a different repository
|
|||||||
General: <https://[service]/CodeBlocks/JavaScript.utils>
|
General: <https://[service]/CodeBlocks/JavaScript.utils>
|
||||||
|
|
||||||
Org: <https://[serverice]/[org]/Code-Blocks.JavaScript.utils>
|
Org: <https://[serverice]/[org]/Code-Blocks.JavaScript.utils>
|
||||||
|
|
||||||
|
### Update NPM packages
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm-check-updates
|
||||||
|
ncu -u
|
||||||
|
npm install
|
||||||
|
```
|
||||||
@@ -18,6 +18,10 @@ export default [
|
|||||||
globals: {
|
globals: {
|
||||||
...globals.browser,
|
...globals.browser,
|
||||||
...globals.jquery
|
...globals.jquery
|
||||||
|
},
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 2022,
|
||||||
|
sourceType: "script",
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
pluginJs.configs.recommended,
|
pluginJs.configs.recommended,
|
||||||
|
|||||||
+4
-4
@@ -9,9 +9,9 @@
|
|||||||
"license": "",
|
"license": "",
|
||||||
"description": "Core Libraries",
|
"description": "Core Libraries",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.20.0",
|
"@eslint/js": "^10.0.1",
|
||||||
"esbuild": "^0.25.0",
|
"esbuild": "^0.28.1",
|
||||||
"eslint": "^9.20.1",
|
"eslint": "^10.5.0",
|
||||||
"globals": "^15.15.0"
|
"globals": "^17.7.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,4 +23,10 @@
|
|||||||
<directory>./www/lib/CoreLibs</directory>
|
<directory>./www/lib/CoreLibs</directory>
|
||||||
</include>
|
</include>
|
||||||
</source> -->
|
</source> -->
|
||||||
|
<logging>
|
||||||
|
<!-- JUnit XML log (Most Common for CI/CD) -->
|
||||||
|
<junit outputFile="build/logs/junit.xml"/>
|
||||||
|
<!-- TestDox HTML log -->
|
||||||
|
<testdoxHtml outputFile="build/testdox.html"/>
|
||||||
|
</logging>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
+1
-1
@@ -15,7 +15,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"repositories": {
|
"repositories": {
|
||||||
"git.egplusww.jp.Composer": {
|
"packages.omnicomproduction.jp.Composer": {
|
||||||
"type": "composer",
|
"type": "composer",
|
||||||
"url": "https://packages.omnicomproduction.jp/api/packages/Composer/composer"
|
"url": "https://packages.omnicomproduction.jp/api/packages/Composer/composer"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class File
|
|||||||
* @param string $read_file File to read, relative or absolute path
|
* @param string $read_file File to read, relative or absolute path
|
||||||
* @return string mime type
|
* @return string mime type
|
||||||
* @throws \UnexpectedValueException if file cannot be read or is not a file
|
* @throws \UnexpectedValueException if file cannot be read or is not a file
|
||||||
* @throws \RangeException if we cannot get a mime type and throw exception is on
|
* @throws \RangeException if we cannot get a mime type
|
||||||
*/
|
*/
|
||||||
public static function getMimeType(string $read_file): string
|
public static function getMimeType(string $read_file): string
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -811,6 +811,87 @@ class ArrayHandler
|
|||||||
);
|
);
|
||||||
return $in_array;
|
return $in_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: move to CoreLibs ArrayCombined
|
||||||
|
* return one random entry from an array (value)
|
||||||
|
* the return entry is null if the incoming array is empty
|
||||||
|
* the array can also be an array of arrays
|
||||||
|
*
|
||||||
|
* @param array<mixed> $array
|
||||||
|
* @return string|int|float|bool|array<mixed>|null
|
||||||
|
*/
|
||||||
|
public static function getRandomEntryFromArray(array $array): string|int|float|bool|array|null
|
||||||
|
{
|
||||||
|
if (empty($array)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$random_index = array_rand($array);
|
||||||
|
return $array[$random_index];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: move to CoreLibs ArrayCombined
|
||||||
|
* find and remove one value
|
||||||
|
* on default removes only the first entry
|
||||||
|
* on default does not strict compare
|
||||||
|
*
|
||||||
|
* @param array<mixed> $array
|
||||||
|
* @param string|int|float|bool|array<mixed> $value
|
||||||
|
* @param bool $strict [false]
|
||||||
|
* @return array<mixed>
|
||||||
|
*/
|
||||||
|
public static function removeArrayEntryByValue(
|
||||||
|
array $array,
|
||||||
|
string|int|float|bool|array $value,
|
||||||
|
bool $strict = false,
|
||||||
|
): array {
|
||||||
|
return array_filter($array, function ($element) use ($value, $strict) {
|
||||||
|
return $strict ?
|
||||||
|
$element !== $value :
|
||||||
|
$element != $value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: move to CoreLibs ArrayCombined
|
||||||
|
* add a string to each element in an array, default is at the end of the value,
|
||||||
|
* can be switched with the prefix flag
|
||||||
|
*
|
||||||
|
* @param array<string> $array
|
||||||
|
* @param string $string_to_add
|
||||||
|
* @param bool $prefix [false]
|
||||||
|
* @return array<string>
|
||||||
|
*/
|
||||||
|
public static function addStringToEachValueInArray(array $array, string $string_to_add, bool $prefix = false): array
|
||||||
|
{
|
||||||
|
return array_map(function ($value) use ($string_to_add, $prefix) {
|
||||||
|
return $prefix ?
|
||||||
|
$string_to_add . $value :
|
||||||
|
$value . $string_to_add;
|
||||||
|
}, $array);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sort by key any array, even if it is nested
|
||||||
|
*
|
||||||
|
* @param array<mixed> $data
|
||||||
|
* @return array<mixed>
|
||||||
|
*/
|
||||||
|
public static function createSortedArrayByKey(array $data): array
|
||||||
|
{
|
||||||
|
// Sort by keys
|
||||||
|
ksort($data);
|
||||||
|
|
||||||
|
// Recursively sort nested arrays
|
||||||
|
foreach ($data as $key => $value) {
|
||||||
|
if (is_array($value)) {
|
||||||
|
$data[$key] = self::createSortedArrayByKey($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
Reference in new issue
Block a user