dist/axis3d.js
//replace defined macros from a string
replace defined macros from a string
replace defined macros from a string
function processFunction(str, name, fn) {
		var arr = [];
		str = escape(str, arr);
		var parts = paren(str, {
			flat: true,
			brackets: '()',
			escape: '___'
		});
		var re = new RegExp(name + '\\s*\\(___([0-9]+)\\)', 'g');
		parts = parts.map(function (part) {
			return part.replace(re, function (match, argsPartIdx) {
				var args = parts[argsPartIdx];
				if (args.trim().length) {
					args = args.split(/\s*,\s*/);
					args = args.map(function (arg) {
						var argParts = parts.slice();
						argParts[0] = arg;
						return paren.stringify(argParts, { flat: true, escape: '___' });
					}).map(function (arg) {
						return arg;
					});
				} else {
					args = [];
				}
				if (args.length != fn.length) throw Error('macro "' + name + '" requires ' + fn.length + ' arguments, but ' + args.length + ' given');
				return fn.apply(null, args);
			});
		});
		str = paren.stringify(parts, { flat: true, escape: '___' });
		str = unescape(str, arr);
		return str;
	}
function processFunction ( str , name , fn ) { var arr = [ ] ; str = escape ( str , arr ) ; var parts = paren ( str , { flat : true , brackets : '()' , escape : '___' } ) ; var re = new RegExp ( name + '\\s*\\(___([0-9]+)\\)' , 'g' ) ; parts = parts . map ( function ( part ) { return part . replace ( re , function ( match , argsPartIdx ) { var args = parts [ argsPartIdx ] ; if ( args . trim ( ) . length ) { args = args . split ( / \s*,\s* / ) ; args = args . map ( function ( arg ) { var argParts = parts . slice ( ) ; argParts [ 0 ] = arg ; return paren . stringify ( argParts , { flat : true , escape : '___' } ) ; } ) . map ( function ( arg ) { return arg ; } ) ; } else { args = [ ] ; } if ( args . length != fn . length ) throw Error ( 'macro "' + name + '" requires ' + fn . length + ' arguments, but ' + args . length + ' given' ) ; return fn . apply ( null , args ) ; } ) ; } ) ; str = paren . stringify ( parts , { flat : true , escape : '___' } ) ; str = unescape ( str , arr ) ; return str ; }
replace defined macros from a string
replace defined macros from a string
//replace each macro call with result //parse arguments //apply macro call with args