hldy_xcx/compontent/public/issame.js

26 lines
751 B
JavaScript

export function shallowEqualObjects(a, b) {
if (a === b) return true;
if (!a || !b) return false;
if (typeof a !== 'object' || typeof b !== 'object') return false;
const keysA = Object.keys(a);
const keysB = Object.keys(b);
if (keysA.length !== keysB.length) return false;
for (const key of keysA) {
if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
if (a[key] !== b[key]) return false; // 用严格相等
}
return true;
}
// 通用的生成函数
export function genPaths(base, prefix, count, ext = 'png', startIndex = 0, pad = false) {
return Array.from({
length: count
}, (_, i) => {
const idx = pad ?
String(i + startIndex).padStart(2, '0') :
i + startIndex
return `${base}/${prefix}${idx}.${ext}`
})
}