feat: support random function range arguments#657
Merged
MakinoharaShoko merged 1 commit intoApr 1, 2025
Conversation
| const valExp = sentence.content.split(/\s*=\s*/)[1]; | ||
| if (valExp === 'random()') { | ||
| webgalStore.dispatch(targetReducerFunction({ key, value: Math.random() })); | ||
| if (/^\s*[a-zA-Z_$][\w$]*\s*\(.*\)\s*$/.test(valExp)) { |
Member
Author
There was a problem hiding this comment.
应该明确判断是和 random 相关联
这个主要是匹配xxx(...xxx)这种函数调用,因为想到以后的可扩展性
| const instance = expression.compile(val); | ||
| return instance({ | ||
| random: (...args: any[]) => { | ||
| return args.length ? random(...args) : Math.random(); |
Member
There was a problem hiding this comment.
lodash 的 random 不能不传参数吗
Member
Author
There was a problem hiding this comment.
lodash 的 random 不能不传参数吗
它不传参只返回0和1,不符合 预期的不传参为浮点数
KonshinHaoshin
pushed a commit
to KonshinHaoshin/WebGAL_Eastmount
that referenced
this pull request
Nov 7, 2025
…ents feat: support random function range arguments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
为
random提供了参数选项,与lodash相同的参数:issue : #654