UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

39 lines (35 loc) 792 B
/** * Returns one argument from a space-separated arguments list * * @remarks * It takes 2 arguments. * * `arg(arguments, index)` * * - `arguments` space-separated arguments list * - `index` index of argument to return * * ## Usage * * - `opnane('a b c', 1)` - returns '1' * - `opname('this is great or is it not', 2)` - returns 'great' * */ import {BaseMethod} from './_Base'; export class ArgExpression extends BaseMethod { static override requiredArguments() { return [ ['string', 'arguments list'], ['number', 'index'], ]; } override async processArguments(args: any[]): Promise<any> { if (args.length == 2) { const argumentsList = args[0]; const index = args[1]; const val = argumentsList.split(' ')[index]; return val; } return 0; } }