MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / destructuringPatternRecursive

Function destructuringPatternRecursive

lib/web/jshint.js:22322–22458  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

22320 }
22321
22322 function destructuringPatternRecursive(options) {
22323 var ids;
22324 var identifiers = [];
22325 var openingParsed = options && options.openingParsed;
22326 var isAssignment = options && options.assignment;
22327 var recursiveOptions = isAssignment ? { assignment: isAssignment } : null;
22328 var firstToken = openingParsed ? state.tokens.curr : state.tokens.next;
22329
22330 var nextInnerDE = function() {
22331 var ident;
22332 if (checkPunctuators(state.tokens.next, ["[", "{"])) {
22333 ids = destructuringPatternRecursive(recursiveOptions);
22334 for (var id in ids) {
22335 id = ids[id];
22336 identifiers.push({ id: id.id, token: id.token });
22337 }
22338 } else if (checkPunctuator(state.tokens.next, ",")) {
22339 identifiers.push({ id: null, token: state.tokens.curr });
22340 } else if (checkPunctuator(state.tokens.next, "(")) {
22341 advance("(");
22342 nextInnerDE();
22343 advance(")");
22344 } else {
22345 var is_rest = checkPunctuator(state.tokens.next, "...");
22346
22347 if (isAssignment) {
22348 var assignTarget = expression(20);
22349 if (assignTarget) {
22350 checkLeftSideAssign(assignTarget);
22351
22352 // if the target was a simple identifier, add it to the list to return
22353 if (assignTarget.identifier) {
22354 ident = assignTarget.value;
22355 }
22356 }
22357 } else {
22358 ident = identifier();
22359 }
22360 if (ident) {
22361 identifiers.push({ id: ident, token: state.tokens.curr });
22362 }
22363 return is_rest;
22364 }
22365 return false;
22366 };
22367 var assignmentProperty = function() {
22368 var id;
22369 if (checkPunctuator(state.tokens.next, "[")) {
22370 advance("[");
22371 expression(10);
22372 advance("]");
22373 advance(":");
22374 nextInnerDE();
22375 } else if (state.tokens.next.id === "(string)" ||
22376 state.tokens.next.id === "(number)") {
22377 advance();
22378 advance(":");
22379 nextInnerDE();

Callers 2

destructuringPatternFunction · 0.85
nextInnerDEFunction · 0.85

Calls 6

checkPunctuatorFunction · 0.85
warningFunction · 0.85
nextInnerDEFunction · 0.85
assignmentPropertyFunction · 0.85
advanceFunction · 0.70
expressionFunction · 0.70

Tested by

no test coverage detected