forked from enviPath/enviPy
Current Dev State
This commit is contained in:
29
static/js/ketcher2/node_modules/accessory/index.js
generated
vendored
Normal file
29
static/js/ketcher2/node_modules/accessory/index.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
'use strict'
|
||||
|
||||
var split = require('dot-parts')
|
||||
var balanced = require('balanced-match')
|
||||
var ap = require('ap')
|
||||
var findCall = ap.partial(balanced, '(', ')')
|
||||
|
||||
module.exports = function createAccessor (source, path) {
|
||||
return split(path).reduce(accumulate, source)
|
||||
}
|
||||
|
||||
function accumulate (statement, property) {
|
||||
var callString = ''
|
||||
function append (body) {
|
||||
callString += '(' + body + ')'
|
||||
}
|
||||
var call = findCall(property)
|
||||
if (call) {
|
||||
property = call.pre
|
||||
append(call.body)
|
||||
var post = call.post
|
||||
}
|
||||
while (post) {
|
||||
call = findCall(post)
|
||||
append(call.body)
|
||||
post = call.post
|
||||
}
|
||||
return statement + "['" + property + "']" + callString
|
||||
}
|
||||
Reference in New Issue
Block a user