How to use the linq.from function in linq

To help you get started, we’ve selected a few linq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github data-forge / data-forge-js / src / basedataframe.js View on Github external
return new ArrayIterator(
						E.from(self.toValues())
							.select(function (row, rowIndex) {
								return row.concat([data[rowIndex]]);
							})
							.toArray()
					);
				},
			},
			index: self.getIndex(),
		});
	}
	else {
		// Replace existing column.
		return new DataFrame({
			columnNames: E.from(self.getColumnNames())
				.select(function (thisColumnName, thisColumnIndex) {
					if (thisColumnIndex === columnIndex) {
						return columnName;
					}
					else { 
						return thisColumnName;
					}
				})
				.toArray(),
			rows: {
				getIterator: function () {
					return new ArrayIterator(
						E.from(self.toValues())
							.select(function (row, rowIndex) {
								return E.from(row)
									.select(function (column, thisColumnIndex) {
github data-forge / data-forge-js / src / series.js View on Github external
return value;
		};
	}

	var self = this;

	//todo: make this lazy.

	/* todo: Want to zip here, when zip can specify the index. 

	series.zip(series.skip(1), function (prev, next) { 
		});

	*/

	var input = E.from(self.toPairs())
		.select(function (pair) {
			return {
				pair: pair,
				considered: false,
			};
		})
		.toArray();

	var output = [];

	for (var i = 0; i < input.length; ++i) {
		var underConsideration = input[i];
		if (underConsideration.considered) {
			// Skip this item, it has already been dealt with.
			continue;
		}
github sky-uk / api-explorer / packages / apiexplorer / src / infrastructure / loaders / swagger1Loader.js View on Github external
.then(apiSpec => {
      let newApiSpec = executeInterceptor(config, apiSpec)
      let defaultHost = new URI(config.url.url).host()

      onLoadProgress(`Loading content from '${url}' completed`)
      const apis = Enumerable
        .from(newApiSpec.apis)
        .select(api => {
          return { path: api.path, url: config.url.resolveChildUrl(`${apiSpec.basePath}${api.path}`), onLoadProgress: onLoadProgress, config }
        })
        .toArray()

      async.map(apis, executeFetch, (err, result) => {
        if (err) {
          onLoadError(`Error loading Swagger 1.x apis: ${err}`)
          console.error(err)
        } else {
          onLoadProgress(`Loading of Swagger spec 1.x completed.`)

          let apiDeclarations = {}
          result.forEach(element => { apiDeclarations[element.path] = element.result })
github sky-uk / api-explorer / packages / apiexplorer / src / components / LateralMenuLegacy.js View on Github external
renderAPI (apiOperations) {
    if (apiOperations.length === 0 || !this.isApiVisible(apiOperations[0].apiname, apiOperations)) return

    const tags = Enumerable.from(apiOperations).selectMany(o => o.spec.tags).distinct().toArray()
    return (
      <li>
        <a href="#">
          <i>
          <span>
          <strong>{apiOperations[0].apiname}</strong><span>
        </span></span></i></a><i>
        <ul>
          {tags.map(tag =&gt; this.renderOperationsWithTag(apiOperations, tag))}
        </ul>
      </i></li><i>
    )
  }
</i>
github data-forge / data-forge-js / src / dataframe.js View on Github external
getColumnNames: function () {
				return E.from(self.iterable.getColumnNames())
					.concat([columnName])
					.distinct()
					.toArray();
			},
		},
github data-forge / data-forge-js / src / basedataframe.js View on Github external
BaseDataFrame.prototype.setSeries = function (columnName, data) { //todo: should allow column name or index.
	assert.isString(columnName, "Expected 'columnName' parameter to 'setSeries' to be a string.");

	var self = this;

	if (Object.isFunction(data)) {
		data = E.from(self.toObjects())
			.select(data)
			.toArray();
	}
	else if (!Object.isArray(data)) {
		assert.isObject(data, "Expected 'data' parameter to 'setSeries' to be either an array or a series object.");
		assert.isFunction(data.reindex, "Expected 'data' parameter to 'setSeries' to have a 'reindex' function that allows the column to be reindexed.");

		data = data.reindex(self.getIndex()).toValues();
	}

	//todo: overview and improve the way this works.

	var DataFrame = require('./dataframe');

	var columnIndex = self.getColumnIndex(columnName);
	if (columnIndex &lt; 0) {
github data-forge / data-forge-js / src / merge-dataframes.js View on Github external
var leftPairs = leftDataFrame.toPairs();
		var rightPairs = rightDataFrame.toPairs();

		var mergedColumnNames = [columnName]
			.concat(dropElement(leftDataFrame.getColumnNames(), leftColumnIndex))
			.concat(dropElement(rightDataFrame.getColumnNames(), rightColumnIndex));

		var leftColumns = leftDataFrame.getColumnNames();
		var rightColumns = rightDataFrame.getColumnNames();

		var leftIndices = E.from(leftPairs)
			.select(function (leftPair) {
				return leftPair[1][leftColumns[leftColumnIndex]];
			})
			.toArray();
		var rightIndices = E.from(rightPairs)
			.select(function (rightPair) {
				return rightPair[1][rightColumns[rightColumnIndex]];
			})
			.toArray();

		var distinctIndices = E.from(leftIndices.concat(rightIndices)).distinct().toArray();

		var leftMap = E.from(leftPairs)
			.groupBy(function (leftPair) {
				return leftPair[1][leftColumns[leftColumnIndex]];
			})
			.toObject(
				function (group) {
					return group.key();
				},
				function (group) {
github data-forge / data-forge-js / src / dataframe.js View on Github external
function (row) {
			return E.from(columnNames)
				.select(function (columnName, columnIndex) {
					return [columnName, columnIndex];
				})
				.toObject(
					function (column) {
						return column[0];
					},
					function (column) {
						return row[column[1]];
					}
				);							
		}
	);
github CYBRToken / solidoc / builders / function-code-builder.js View on Github external
return builder.join("");
    }

    if(!node || !node.parameters) {
      return "";
    }

    const builder = [];

    const parameters = node.parameters.parameters || [];
    const documentation = node.documentation;

    const returnDocumentation = documentationHelper.get(documentation, "return");
    const parameterList = [];

    const modifierList = enumerable.from(node.modifiers).select(function(x) {
      return x.modifierName.name;
    }).toArray();

    for(let i in parameters) {
      const parameter = parameters[i];
      const argumentName = parameter.name;
      const dataType = parameter.typeDescriptions.typeString.replace("contract ", "");
      parameterList.push(`${dataType} ${argumentName}`);
    }

    builder.push("```js");
    builder.push("\n");
    builder.push(`function ${node.name}(`);

    builder.push(parameterList.join(", "));
github data-forge / data-forge-js / src / series.js View on Github external
.aggregate({}, function (accumulated, value) {
					var valueKey = (value !== null && value.toString() || "null") + "-" + typeof(value);
					var valueInfo = accumulated[valueKey];
					if (!valueInfo) {
						valueInfo = {
							count: 0,
							value: value,
						};
						accumulated[valueKey] = valueInfo;
					}
					++valueInfo.count;
					return accumulated;
				});

			return new ArrayIterator(
				E.from(Object.keys(valueFrequencies))
					.select(function (valueKey) {
						var valueInfo = valueFrequencies[valueKey];
						return [
							valueInfo.value,
							(valueInfo.count / totalValues) * 100
						];
					})
					.toArray()
			);
		},
	});

linq

linq.js - LINQ for JavaScript

MIT
Latest version published 6 months ago

Package Health Score

64 / 100
Full package analysis

Popular linq functions