diff --git a/CHANGELOG.md b/CHANGELOG.md index 6585d75..94166bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,18 @@ # 更新日志 +## [v4.1.3](https://github.com/buession/buession-prototype/releases/tag/4.1.3)(2025-04-10) + +### 🐞 BUG 修复 + +- 修复生成 AMD 和 CommonJS 时,版本占位符未被替换成实际版本的 BUG +- 修复 Date.prototype.getDayOfYear 错误的 BUG + +### ⏪ 优化 + +- 其它优化 + + ## [v4.1.2](https://github.com/buession/buession-prototype/releases/tag/4.1.2)(2025-04-09) diff --git a/babel.config.js b/babel.config.js index b8b6959..a877d79 100644 --- a/babel.config.js +++ b/babel.config.js @@ -10,8 +10,6 @@ module.exports = { } ], '@babel/plugin-transform-optional-chaining', - '@babel/plugin-transform-object-assign', - '@babel/plugin-transform-object-rest-spread', '@babel/plugin-proposal-export-default-from', '@babel/plugin-transform-export-namespace-from', '@babel/plugin-transform-class-properties', diff --git a/build/gulpfile.js b/build/gulpfile.js index 355693a..ff698fa 100644 --- a/build/gulpfile.js +++ b/build/gulpfile.js @@ -18,6 +18,8 @@ const getTSCommonConfig = require('./getTSCommonConfig'); const replaceLib = require('./replaceLib'); const sortApiTable = require('./sortApiTable'); +const pkg = require('../package.json'); + const tsDefaultReporter = ts.reporter.defaultReporter(); const libDir = getProjectPath('lib'); @@ -37,7 +39,7 @@ function babelify(js, modules) { if (modules !== false) { const content = file.contents.toString(encoding); file.contents = Buffer.from( - content.replace(/lodash-es/g, 'lodash') + content.replace(/lodash-es/g, 'lodash').replace('__VERSION__', pkg.version) ); this.push(file); } diff --git a/build/utils/CleanUpStatsPlugin.js b/build/utils/CleanUpStatsPlugin.js index 6ec1af9..17cb7bf 100644 --- a/build/utils/CleanUpStatsPlugin.js +++ b/build/utils/CleanUpStatsPlugin.js @@ -2,15 +2,12 @@ class CleanUpStatsPlugin { constructor(option) { this.option = { - MiniCSSExtractPlugin: true, tsLoader: true, ...option, }; } shouldPickStatChild(child) { - const { MiniCSSExtractPlugin } = this.option; - if (MiniCSSExtractPlugin && child.name.includes('mini-css-extract-plugin')) return false; return true; } diff --git a/package.json b/package.json index db688f5..a000dd8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@buession/prototype", "alias": "prototype", - "version": "v4.1.2", + "version": "v4.1.3", "description": "A native object extension framework for Javascript.", "homepage": "https://prototype.buession.com/", "author": { @@ -48,8 +48,6 @@ "@babel/plugin-transform-class-properties": "^7.25.9", "@babel/plugin-transform-export-namespace-from": "^7.25.9", "@babel/plugin-transform-member-expression-literals": "^7.8.3", - "@babel/plugin-transform-object-assign": "^7.25.9", - "@babel/plugin-transform-object-rest-spread": "^7.25.9", "@babel/plugin-transform-optional-chaining": "^7.25.9", "@babel/plugin-transform-property-literals": "^7.8.3", "@babel/plugin-transform-runtime": "^7.26.10", diff --git a/site/src/index.jsx b/site/src/index.jsx index 74ccc96..2c4cffb 100644 --- a/site/src/index.jsx +++ b/site/src/index.jsx @@ -5,7 +5,7 @@ banner: btns: - { name: '开 始', href: '/docs/quickstart.html', primary: true } - { name: 'Github >', href: 'https://github.com/buession/buession-prototype' } - caption: '当前版本: v4.1.1' + caption: '当前版本: v4.1.3' features: - { name: '优雅', desc: '旨在提供便捷的、可靠的基于原生 JavaScript/TypeScript 扩展的类库,拥有完善的文档和高可读性的源码' } - { name: '易用', desc: '觉大部分 API 基于原生 JavaScript/TypeScript 对象/类的扩展,参考学习 prototype.js' } diff --git a/src/array.ts b/src/array.ts index 11733de..49d255b 100644 --- a/src/array.ts +++ b/src/array.ts @@ -187,9 +187,7 @@ Array.prototype.unique = function(): Array { * @return 不包括参数中任意一个指定值的数组 */ Array.prototype.without = function(...values: T[]): Array { - return this.filter(function(v: T) { - return values.includes(v) === false; - }); + return this.filter((value)=>values.includes(value) === false); } /** diff --git a/src/core.ts b/src/core.ts index 29b3eeb..c700c1d 100644 --- a/src/core.ts +++ b/src/core.ts @@ -8,6 +8,8 @@ export type Oun = T | Un; export type MaybeArray = T | T[]; +export type MaybePromise = T | Promise; + export type GenericData = Record; export type Data = GenericData; diff --git a/src/date.ts b/src/date.ts index 124c942..6b4c17b 100644 --- a/src/date.ts +++ b/src/date.ts @@ -112,11 +112,11 @@ Date.prototype.getSeason = function(): number { * @return 年份中的第几天 */ Date.prototype.getDayOfYear = function(): number { - const month_days = this.isLeapYear() == true ? [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] : [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; - let days = this.getDate(); + const daysInMonth = [31, this.isLeapYear() ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; + let days = 0; for (let m = 0, month = this.getMonth(); m < month; m++) { - days += month_days[m]; + days += daysInMonth[m]; } return days; diff --git a/src/number.ts b/src/number.ts index 1f5772e..d15d0b7 100644 --- a/src/number.ts +++ b/src/number.ts @@ -86,8 +86,8 @@ Number.isEven = function(num: number): boolean { * @return boolean 数字是否在另两个数字之间,返回 true;否则返回 false */ Number.isBetween = function(num: number, min: number, max: number, match: boolean | undefined = false): boolean { - min = min||0; - max = max||0; + min = min || 0; + max = max || 0; if (min > max) { min ^= max; diff --git a/src/prototype.ts b/src/prototype.ts index 3b45600..63af697 100644 --- a/src/prototype.ts +++ b/src/prototype.ts @@ -18,10 +18,10 @@ const Prototype = { }, /** - * - * @param x 任意参数 - * @return 任意值 - */ + * + * @param x 任意参数 + * @return 任意值 + */ K: function (x: any): any { return x; }