Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
56 lines (46 loc) · 1.77 KB

File metadata and controls

56 lines (46 loc) · 1.77 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* Copyright 2012-2018, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
var Registry = require('../registry');
/*
* containerArrayMatch: does this attribute string point into a
* layout container array?
*
* @param {String} astr: an attribute string, like *annotations[2].text*
*
* @returns {Object | false} Returns false if `astr` doesn't match a container
* array. If it does, returns:
* {array: {String}, index: {Number}, property: {String}}
* ie the attribute string for the array, the index within the array (or ''
* if the whole array) and the property within that (or '' if the whole array
* or the whole object)
*/
module.exports = function containerArrayMatch(astr) {
var rootContainers = Registry.layoutArrayContainers,
regexpContainers = Registry.layoutArrayRegexes,
rootPart = astr.split('[')[0],
arrayStr,
match;
// look for regexp matches first, because they may be nested inside root matches
// eg updatemenus[i].buttons is nested inside updatemenus
for(var i = 0; i < regexpContainers.length; i++) {
match = astr.match(regexpContainers[i]);
if(match && match.index === 0) {
arrayStr = match[0];
break;
}
}
// now look for root matches
if(!arrayStr) arrayStr = rootContainers[rootContainers.indexOf(rootPart)];
if(!arrayStr) return false;
var tail = astr.substr(arrayStr.length);
if(!tail) return {array: arrayStr, index: '', property: ''};
match = tail.match(/^\[(0|[1-9][0-9]*)\](\.(.+))?$/);
if(!match) return false;
return {array: arrayStr, index: Number(match[1]), property: match[3] || ''};
};
Morty Proxy This is a proxified and sanitized view of the page, visit original site.