Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)


Expand Down
2 changes: 0 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 3 additions & 1 deletion build/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
}
Expand Down
3 changes: 0 additions & 3 deletions build/utils/CleanUpStatsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion site/src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand Down
4 changes: 1 addition & 3 deletions src/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,7 @@ Array.prototype.unique = function<T>(): Array<T> {
* @return 不包括参数中任意一个指定值的数组
*/
Array.prototype.without = function<T>(...values: T[]): Array<T> {
return this.filter(function(v: T) {
return values.includes(v) === false;
});
return this.filter((value)=>values.includes(value) === false);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export type Oun<T> = T | Un;

export type MaybeArray<T> = T | T[];

export type MaybePromise<T> = T | Promise<T>;

export type GenericData<T> = Record<string, T>;

export type Data = GenericData<any>;
6 changes: 3 additions & 3 deletions src/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/prototype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ const Prototype = {
},

/**
*
* @param x 任意参数
* @return 任意值
*/
*
* @param x 任意参数
* @return 任意值
*/
K: function (x: any): any {
return x;
}
Expand Down