@function applyModelViewCollectionAsynchronous

apply views to results object

@param {object} context
@param {integer} num
@param {array} raw

@returns {Promise}
558402
function applyModelViewCollectionAsynchronous (context, num, raw) {
    // get data column
    var dataColumn = this.query.model.columnName('data')
    // apply model views to data
    return Promise.all(_.map(this.modelViews.collection.asynchronous, modelView => {
        // if this model view applies to meta data then pass entire db record
        var data = modelView.meta ? raw : raw[dataColumn]
        // call each function with modelView and data
        return modelView.each({
            context: context,
            modelView: modelView,
            number: num,
            record: data,
            session: this.query.session,
        })
        // merge result to data
        .then((eachContext => {
            _.merge(context, eachContext)
        }))
    }))
    // resolve with merged context
    .then(() => context)
}
1316042
function updateCollected(err, result) {
            if (typeof result !== 'object') {
                collection.err = collection.err || new Error('Invalid acrhitect plugin format');
                return;
            }

            collection.err = collection.err || err;

            if (!collection.loaded) {
                collection.result = result;
                collection.loaded = true;
                return;
            }

            for (var i in result) {
                if (result.hasOwnProperty(i)) {
                    if (collection.result.hasOwnProperty(i)) {
                        collection.err = collection.err || new Error('Service overloading not supported: ' + i);
                        return;
                    }
                    collection.result[i] = result[i];
                }
            }
        }
1056681
function updateDOM(source,target,scope,actions,view=target,template=source) {
		Object.defineProperty(target,"view",{enumerable:false,configurable:true,writable:true,value:view});
		Object.assign(scope,{"$source":source,
												"$target":target,
												"$template":template.children ? (template.children.length> 1 ? template.children : template.children[0]) : template,
												"$view":view.children.length> 1 ? view.children : view.children[0]});
		// if source and target are text
		if(typeof(source)==="string") {
			const value = (resolve(source,scope,actions)+""),
					doc = new DOMParser().parseFromString(value, "text/html"),
		  		children = slice(doc.body.childNodes);
		  if(children.some(node => node.nodeType === 1)) {
		  	updateDOM(toVDOM(doc.body),doc.body,scope,actions,view,template);
		  	let parent;
		  	if(target.nodeType===3) {
			  	parent = target.parentElement;
			  	parent.removeChild(target);
		  	} else if(target.nodeType===1) {
		  		parent = target;
		  		while(parent.lastChild) parent.removeChild(parent.lastChild);
		  	}
		  	slice(doc.body.childNodes).forEach(child => parent.appendChild(child));
		  } else if(target.data!==value) {
		  	target.data = value;
		  }
		  return view;
		}
		target.view.template = target.view.innerHTML;
		// if tags aren't the same
		if(source.tagName!==target.tagName) {
			// replace the target with the source
			if(target.parentNode) {
				const el = document.createElement(source.tagName);
				target.parentNode.replaceChild(el,target);
				target = el;
			}
		}
		// loop through target attributes, remove where does not exist in source
			slice(target.attributes).forEach(attribute => source.attributes[attribute.name]!==null || target.removeAttribute(attribute.name));
			// loop through source attributes
			let directed;
			Object.keys(source.attributes).forEach(aname => {
				let value = source.attributes[aname],
				 type = typeof(value),
				 currentview = CURRENTVIEW;
				CURRENTVIEW = target;
				const dname = resolve(aname.split(":")[0],scope,actions),
					directive = directives[dname]||tlx.directives[dname];
				value = resolve(value,scope,actions);
				CURRENTVIEW = currentview;
				type = typeof(value);
				// replace different
				if(value==null) {
					target.removeAttribute(aname);
					delete target[aname];
				} else if(["boolean","number","string"].includes(type)) {
					if(value!==target.getAttribute(aname)) {
						try {
							target.setAttribute(aname,value);
							if(aname==="value") target.value = value;
						} catch(e) {
							; // just ignore, may be an attribute with an unresolved argument, e.g. t-bind:${aname}
						}
					}
				} else {
						const pname = toPropertyName(aname);
						if(value!==target[pname]) target[pname] = value;
				}
				if(directive) { 
					while(target.lastChild) target.removeChild(target.lastChild); 
					const render = (scope,actions) => {
						source.children.forEach(child => {
							if(typeof(child)==="string") target.appendChild(new Text(child));
							else target.appendChild(document.createElement(child.tagName));
							updateDOM(child,target.lastChild,scope,actions,view,template);
						});
						return target;
					};
					const result = directive(value,scope,actions,render,{element:target,raw:aname,resolved:aname.indexOf("${")>=0 ? resolve(aname,scope,actions) : aname}),
						rtype = typeof(result);
					if(result==null) {
						target.parentElement.removeChild(target);
					} else if(rtype==="string") {
							directed = true;
							target.innerHTML = result;
					} else if(rtype==="object" && result instanceof HTMLElement) {
						directed = true;
						if(result!==target) target.parentElement.replaceChild(result,target);
					}
				}
			});
			if(!directed) {
				// remove extra children
				let remove = target.childNodes.length-source.children.length;
				while(remove-->0) !target.lastChild || target.removeChild(target.lastChild);
				// handle the child nodes
				let targets = slice(target.childNodes,0,source.children.length);
				if(targets.length===0) {
					const shadow = target.shadowRoot;
					if(shadow) targets = slice(shadow.childNodes,0,source.children.length);
				}
				source.children.forEach((child,i) => {
					// update if in range
					if(i<targets.length) {
						updateDOM(child,targets[i],scope,actions,view,template);
						return;
					}
					if(typeof(child)==="string") target.appendChild(new Text());
					else target.appendChild(document.createElement(child.tagName));
					updateDOM(child,target.lastChild,scope,actions,view,template);
				});
			}
		
		return view;
	}
50678
function applyModelViewRecord (raw) {
    // if record is cached view then do not reprocess
    if (raw._cachedView) {
        return Promise.resolve(raw)
    }
    // if there are synchronous views then do sync apply
    if (this.hasRecordSynchronous) {
        this.applyModelViewRecordSynchronous(raw)
    }
    // if there are asychronous views then do async apply
    if (this.hasRecordAsynchronous) {
        return this.applyModelViewRecordAsynchronous(raw)
    }
    // otherwise resolve with result
    else {
        return Promise.resolve(raw)
    }
}
692631
async function render(nj, templ, templateVars) {
  debug('templ before: ', templ);
  // if no vars passed, use
  // template itself as source of variables:
  if (_.isUndefined(templateVars))
    templateVars = JSON.parse(_.cloneDeep(templ));

  templ = await nj.renderStringAsync(templ, templateVars);
  if (templ.match(/\{\{.*\}\}/)) {
    // recurse
    return await render(nj, templ, templateVars);
  }
  return templ;
}
865179
function onData( numValues ) {
		var i = -1, buffer;

		// Initialize the buffer array used for chunking:
		buffer = new Array( numValues );

		/**
		* FUNCTION: onData( newVal, encoding, clbk )
		*	Data event handler. Chunks data.
		*
		* @private
		* @param {Number} newVal - new streamed data value
		* @param {String} encoding
		* @param {Function} clbk - callback to invoke after handling streamed data. Function accepts two arguments: [ error, chunk ].
		*/
		return function onData( newVal, encoding, clbk ) {
			i += 1;
			buffer[ i ] = newVal;
			if ( i === numValues-1 ) {
				i = -1;
				clbk( null, buffer.slice() );
				return;
			}
			clbk();
		}; // end FUNCTION onData()
	}
1094125
@WorkerThread
  public static LottieResult<LottieComposition> fromRawResSync(Context context, @RawRes int rawRes) {
    try {
      return fromJsonInputStreamSync(context.getResources().openRawResource(rawRes), rawResCacheKey(rawRes));
    } catch (Resources.NotFoundException e) {
      return new LottieResult<>(e);
    }
  }
154444
function update(clientModelDoc, callback) {
      var cb = callback || angular.noop;

      return ClientModelDoc.update(clientModelDoc,
        function (clientModelDoc) {
          return cb(clientModelDoc);
        },
        function (err) {
          return cb(err);
        }).$promise;
    }
284281
function runAsync(context, func, callback)
{
  var result
    , requiresContext = isArrowFunction(func)
    ;

  if (requiresContext)
  {
    result = func.call(null, context, callback);
  }
  else
  {
    result = func.call(context, callback);
  }

  return result;
}
1176170
function(model, options) {
      options = options ? _.clone(options) : {};
      var wait = options.wait;
      model = this._prepareModel(model, options);
      if (!model) return false;
      if (!wait) this.add(model, options);
      var collection = this;
      var success = options.success;
      options.success = function(m, resp, callbackOpts) {
        if (wait) collection.add(m, callbackOpts);
        if (success) success.call(callbackOpts.context, m, resp, callbackOpts);
      };
      model.save(null, options);
      return model;
    }
504981
function getResult(attrNode, dataSourceName, context) {
    const resultId = attrNode.dataSources[dataSourceName].resultId;
    if (typeof resultId === 'undefined') {
        const attrPath = context.attrPath.length > 0 ? context.attrPath.join('.') : '{root}';
        throw new ImplementationError(`Result for "${attrPath}" (DataSource "${dataSourceName}") missing`);
    }
    return context.rawResults[resultId];
}
681259
function _runInActiveDataframes (viewportExpressions, renderLayer) {
    const dataframes = renderLayer.getActiveDataframes();
    const inViewportFeaturesIDs = _runInDataframes(viewportExpressions, renderLayer, dataframes);

    _runImprovedForPartialFeatures(viewportExpressions, renderLayer, inViewportFeaturesIDs);
}
1197038
function modelItem(data, model) {
    var res = {};

    utils.defineProperties(res, {
        _isModelItem: { value: true },

        model: { value: model.value },

        update: { value: function(data, sync) {
            if (sync == null) sync = true;

            return update(res, model, data).then(function() {
                if (!sync) return;
                return res.save();
            });
        } },

        save: { value: function() {
            if (_.has(res, 'id')) {
                var props = serverProperties(res, model);
                return utils.socketPost(model.io, model.url + '/update/' + res.id, props.properties).then(function() {
                    return Promise.all(_.map(props.refresh, function(item) {
                        return item.refresh();
                    }));
                });
            }
            return create(res, model);
        } },

        refresh: { value: function() {
            if (!_.has(res, 'id')) return create(res, model);

            return utils.socketGet(model.io, model.url + '/' + res.id).then(function(data) {
                return update(res, model, data, { noRefresh: true });
            });
        } },

        delete: { value: function() {
            model._removeItem(res);
            return utils.socketDelete(model.io, model.url, { id: res.id });
        } },

        matches: { value: function(query) {
            return utils.socketGet(model.io, model.url, query).then(function(r) {
                for (var i = 0; i < r.length; i++) {
                    if (r[i].id === res.id) return true;
                }
                return false;
            });
        } },

        then: { value: function() {
            return res.ready.then.apply(res.ready, arguments);
        } },

        catch: { value: function() {
            return res.ready.catch.apply(res.ready, arguments);
        } }
    });

    res.ready = Promise.resolve();

    update(res, model, data || {});

    return res;
}
521674
function RawEncoder(schema, opts) {
  opts = opts || {};

  stream.Transform.call(this, {
    writableObjectMode: true,
    allowHalfOpen: false
  });

  this._type = types.createType(files.load(schema));
  this._writeValue = function (tap, val) {
    try {
      this._type._write(tap, val);
    } catch (err) {
      this.emit('error', err);
    }
  };
  this._tap = new Tap(new Buffer(opts.batchSize || 65536));
}
44067
function(type, model={}, collection={}, options={}){
    var shortcircuit = { sort: 1, request: 1, destroy: 1, sync: 1, error: 1, invalid: 1, route: 1 };
    if( this.isChanging || !this.tracking || shortcircuit[type] || ~type.indexOf('change:') ){ return void 0; }
    !collection.isData && _.isObject(collection) && (options = collection) && (collection = model);

    var path = collection.__path().replace(this.__path(), '').replace(/^\./, '');

    // Need to pass isPath: true here because when syncing across computed properties
    // that return collections we may just be passing the model index for the path.
    var dest = this.tracking.get(path, {raw: true, isPath: true});

    if(_.isUndefined(dest)){ return void 0; }
    if(type === 'change' && model.changedAttributes()){ dest.set && dest.set(model.changedAttributes()); }
    else if(type === 'reset'){ dest.reset && dest.reset(model); }
    else if(type === 'update'){ dest.set && dest.set(model); }
    else if(type === 'add'){ dest.add && dest.add(model); }
    else if(type === 'remove'){ dest.remove && dest.remove(model); }
    // TODO: Add sort

  }
284670
protected final void invokeDraw(View view, Canvas canvas) {
        final ViewProxy proxy = (ViewProxy) view;
        proxy.invokeDraw(canvas);
    }
348182
function collectionResultPost (context) {
    // if there are synchronous views then execute any post functions
    if (this.hasCollectionSynchronous) {
        _.each(this.modelViews.collection.synchronous, modelView => {
            // if view does not have post function do nothing
            if (!modelView.post) {
                return
            }
            // execute post function and merge result to context
            _.merge(context, modelView.post(context))
        })
    }
    // if there are asynchronous views then execute any post functions
    if (this.hasCollectionAsynchronous) {
        return Promise.all(_.map(this.modelViews.collection.asynchronous, modelView => {
            // if view does not have post function do nothing
            if (!modelView.post) {
                return
            }
            // execute post function
            return modelView.post({
                context: context,
                session: this.query.session,
            }).then(ctx => {
                _.merge(context, ctx)
            })
        }))
        // resolve with context
        .then(() => context)
    }
    // otherwise resolve with context
    else {
        return Promise.resolve(context)
    }
}