Skip to content

Commit 576d36f

Browse files
committed
feat: export isRole function
1 parent 0962644 commit 576d36f

File tree

4 files changed

+25
-28
lines changed

4 files changed

+25
-28
lines changed

package-lock.json

Lines changed: 13 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "scenejs",
3-
"version": "1.4.3",
3+
"version": "1.5.0",
44
"description": "JavaScript & CSS timeline-based animation library",
55
"main": "dist/scene.cjs.js",
66
"module": "dist/scene.esm.js",
@@ -48,7 +48,7 @@
4848
"homepage": "https://daybrush.com/scenejs",
4949
"devDependencies": {
5050
"@daybrush/builder": "^0.1.0",
51-
"@daybrush/jsdoc": "^0.3.7",
51+
"@daybrush/jsdoc": "^0.3.10",
5252
"@daybrush/page": "^0.2.0",
5353
"@daybrush/release": "^0.2.4",
5454
"@types/karma-chai": "^0.1.1",

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ export * from "./easing";
88
export * from "./presets";
99
export * from "./types";
1010
export { OPTIONS, EVENTS, FIXED, ROLES, NAME_SEPARATOR } from "./consts";
11-
export { setRole, setAlias } from "./utils";
11+
export { setRole, setAlias, isRole } from "./utils";
1212
export { Scene as default };

src/utils.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export function getValueByNames(
9898
}
9999
return value;
100100
}
101-
export function isInProperties(roles: IObject<any>, args: NameType[], isCheckTrue?: boolean) {
101+
export function isInProperties(roles: IObject<any>, args: NameType[], isLast?: boolean) {
102102
const length = args.length;
103103
let role: any = roles;
104104

@@ -110,14 +110,19 @@ export function isInProperties(roles: IObject<any>, args: NameType[], isCheckTru
110110
return false;
111111
}
112112
role = role[args[i]];
113-
if (!role || (!isCheckTrue && role === true)) {
113+
if (!role || (!isLast && role === true)) {
114114
return false;
115115
}
116116
}
117117
return true;
118118
}
119-
export function isRole(args: NameType[], isCheckTrue?: boolean) {
120-
return isInProperties(ROLES, args, isCheckTrue);
119+
/**
120+
* @memberof Scene
121+
* @param - Property names
122+
* @param - Whether the property is the last property that cannot be an object (non-partitionable)
123+
*/
124+
export function isRole(args: NameType[], isLast?: boolean): boolean {
125+
return isInProperties(ROLES, args, isLast);
121126
}
122127
export function isFixed(args: NameType[]) {
123128
return isInProperties(FIXED, args, true);

0 commit comments

Comments
 (0)