First commit.

Signed-off-by: Chen Xiao <abigwc@gmail.com>
This commit is contained in:
Chen Xiao
2026-05-08 14:43:16 +08:00
commit 0b64e2de94
10989 changed files with 2253791 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
interface LicenseInfo {
/** Requires attribution */
attribution: boolean;
/** Allows commercial use */
commercial: boolean;
/** Keep same license */
sameLicense?: boolean;
}
/**
* Data for open source licenses used by icon sets in `@iconify/json` package and smaller packages
*
* Key is SPDX license identifier
*/
declare const licensesData: Record<string, LicenseInfo>;
export { LicenseInfo, licensesData };
+56
View File
@@ -0,0 +1,56 @@
/** Completely free, no limits */
const freeLicense = {
attribution: false,
commercial: true
};
/** Requires same license for derived works */
const freeSameLicense = {
attribution: false,
commercial: true,
sameLicense: true
};
/** Requires attribution */
const attribLicense = {
attribution: true,
commercial: true
};
/** Requires attribution and same license for derived works */
const attribSameLicense = {
attribution: true,
commercial: true,
sameLicense: true
};
/**
* Data for open source licenses used by icon sets in `@iconify/json` package and smaller packages
*
* Key is SPDX license identifier
*/
const licensesData = {
"Apache-2.0": freeLicense,
"MIT": freeLicense,
"MPL-2.0": freeLicense,
"CC0-1.0": freeLicense,
"CC-BY-3.0": attribLicense,
"CC-BY-SA-3.0": attribSameLicense,
"CC-BY-4.0": attribLicense,
"CC-BY-SA-4.0": attribSameLicense,
"CC-BY-NC-4.0": {
attribution: true,
commercial: false
},
"CC-BY-NC-SA-4.0": {
attribution: true,
commercial: false,
sameLicense: true
},
"ISC": freeLicense,
"OFL-1.1": freeLicense,
"GPL-2.0-only": freeSameLicense,
"GPL-2.0-or-later": freeSameLicense,
"GPL-3.0": freeSameLicense,
"GPL-3.0-or-later": freeSameLicense,
"Unlicense": freeLicense,
"BSD-2-Clause": freeLicense,
"BSD-3-Clause": freeLicense
};
export { licensesData };
+15
View File
@@ -0,0 +1,15 @@
/**
* Compares two objects, returns true if identical
*
* Reference object contains keys
*/
declare function compareObjects<T extends Record<string, unknown>>(obj1: T, obj2: T, ref?: T): boolean;
/**
* Unmerge objects, removing items that match in both objects
*/
declare function unmergeObjects<T extends Record<string, unknown>>(obj1: T, obj2: T): T;
/**
* Get common properties in 2 objects
*/
declare function commonObjectProps<T extends Record<string, unknown>>(item: unknown, reference: T): Partial<T>;
export { commonObjectProps, compareObjects, unmergeObjects };
+26
View File
@@ -0,0 +1,26 @@
/**
* Compares two objects, returns true if identical
*
* Reference object contains keys
*/
function compareObjects(obj1, obj2, ref = obj1) {
for (const key in ref) if (obj1[key] !== obj2[key]) return false;
return Object.keys(obj1).length === Object.keys(obj2).length;
}
/**
* Unmerge objects, removing items that match in both objects
*/
function unmergeObjects(obj1, obj2) {
const result = { ...obj1 };
for (const key in obj2) if (result[key] === obj2[key]) delete result[key];
return result;
}
/**
* Get common properties in 2 objects
*/
function commonObjectProps(item, reference) {
const result = Object.create(null);
for (const key in reference) if (key in item) result[key] = item[key];
return result;
}
export { commonObjectProps, compareObjects, unmergeObjects };
+17
View File
@@ -0,0 +1,17 @@
/**
* Convert string to camelCase
*/
declare function camelize(str: string): string;
/**
* Convert string to PascaleCase
*/
declare function pascalize(str: string): string;
/**
* Convert camelCase string to kebab-case
*/
declare function camelToKebab(key: string): string;
/**
* Convert camelCase string to snake-case
*/
declare function snakelize(str: string): string;
export { camelToKebab, camelize, pascalize, snakelize };
+26
View File
@@ -0,0 +1,26 @@
/**
* Convert string to camelCase
*/
function camelize(str) {
return str.replace(/-([a-z0-9])/g, (g) => g[1].toUpperCase());
}
/**
* Convert string to PascaleCase
*/
function pascalize(str) {
const camel = camelize(str);
return camel.slice(0, 1).toUpperCase() + camel.slice(1);
}
/**
* Convert camelCase string to kebab-case
*/
function camelToKebab(key) {
return key.replace(/:/g, "-").replace(/([A-Z])/g, " $1").trim().split(/\s+/g).join("-").toLowerCase();
}
/**
* Convert camelCase string to snake-case
*/
function snakelize(str) {
return camelToKebab(str).replace(/-/g, "_");
}
export { camelToKebab, camelize, pascalize, snakelize };
+7
View File
@@ -0,0 +1,7 @@
/**
* Sanitises title, removing any unwanted characters that might break XML.
*
* This is a very basic funciton, not full parser.
*/
declare function sanitiseTitleAttribute(content: string): string;
export { sanitiseTitleAttribute };
+9
View File
@@ -0,0 +1,9 @@
/**
* Sanitises title, removing any unwanted characters that might break XML.
*
* This is a very basic funciton, not full parser.
*/
function sanitiseTitleAttribute(content) {
return content.replace(/[<>&]+/g, "");
}
export { sanitiseTitleAttribute };