-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move some srcs, separate extractDefaults func
- Loading branch information
Showing
4 changed files
with
23 additions
and
19 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export function extractDefaults(def){ | ||
const params = {} | ||
def.forEach(({ name, initial, default: def, type, values, captions }) =>{ | ||
let val = def === undefined ? initial : def | ||
if(type === 'choice' && values.indexOf(v=>v === val) === -1){ | ||
// it is supported for choice to use default value from captions also | ||
// but script will need the matching value | ||
for(let i=0; i<captions.length; i++){ | ||
if(captions[i] === val){ | ||
val = values[i] | ||
break; | ||
} | ||
} | ||
if(val === undefined) val = values[0] | ||
} | ||
params[name] = val | ||
}) | ||
return params | ||
} |
File renamed without changes.
This file contains 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