How to use the linq-js.comparers function in linq-js

To help you get started, we’ve selected a few linq-js 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 wm123450405 / linqjs / pack.js View on Github external
let defaultDirectoryMeta = JSON.parse(fs.readFileSync(path.join(resources, common.defaultLang, directoryMetaFile)));
	let defaultCaption = JSON.parse(fs.readFileSync(path.join(resources, common.defaultLang, captionFile)));
	let defaultGuides = Enumerable(fs.readdirSync(path.join(resources, common.defaultLang, 'guides'))).where(name => path.extname(name) === jsonExt).orderBy(element => path.basename(element, jsonExt), Enumerable.comparers.array([
		"instance", "use", "config", "selector", "predicate", "comparer", "action", "setter", "iterator"
	], true)).toArray();
	let defaultApis = Enumerable(fs.readdirSync(path.join(resources, common.defaultLang, 'apis'))).where(name => path.extname(name) === jsonExt).orderBy(element => path.basename(element, jsonExt)).toArray();
	// let defaultChanges = Enumerable(fs.readdirSync(path.join(resources, common.defaultLang, 'change'))).where(name => path.extname(name) === jsonExt).orderBy(element => path.basename(element, jsonExt), (element, other) => {
	// 	if (element === other) {
	// 		return 0;
	// 	} else if (common.isNewer(element, other)) {
	// 		return -1;
	// 	} else {
	// 		return 1;
	// 	}
	// }).toArray();
	let defaultChanges = Enumerable(fs.readdirSync(path.join(resources, common.defaultLang, 'change'))).where(name => path.extname(name) === jsonExt).orderBy(element => path.basename(element, jsonExt), Enumerable.comparers.less(common.isNewer)).toArray();

	common.versions = Enumerable.select(defaultChanges, change => path.basename(change, jsonExt)).toArray();
	fs.writeFileSync(path.join(resources, 'versions.json'), JSON.stringify(common.versions));
	let versions = [...common.versions];
    if (!versions[versions.length - 1].endsWith('pre')) versions.push(common.preVersion(versions[versions.length - 1]));
    fs.writeFileSync(path.join(scripts, 'histroy.js'), 'module.exports = (version, callback, pre, post) => { ' + versions.reverse().map(version => `if (version === '${ version }') return require.ensure([], function(require) { if (callback) { pre && pre(); callback(require('${ common.module(version) }')); post && post(); } }, '${ common.module(version) }');`).join(' else ') + ' };');

	console.log('apis:' + defaultApis);

	let langNames = fs.readdirSync(resources);
	for (let langName of langNames) {
		if (typeof refreshLangName !== 'undefined' && common.defaultLang !== refreshLangName && langName !== refreshLangName) {
			continue;
		}
		let langPath = path.join(resources, langName);
		if (fs.statSync(langPath).isDirectory()) {
github wm123450405 / linqjs / pack.js View on Github external
const createDirectory = refreshLangName => {
	let defaultDirectoryMeta = JSON.parse(fs.readFileSync(path.join(resources, common.defaultLang, directoryMetaFile)));
	let defaultCaption = JSON.parse(fs.readFileSync(path.join(resources, common.defaultLang, captionFile)));
	let defaultGuides = Enumerable(fs.readdirSync(path.join(resources, common.defaultLang, 'guides'))).where(name => path.extname(name) === jsonExt).orderBy(element => path.basename(element, jsonExt), Enumerable.comparers.array([
		"instance", "use", "config", "selector", "predicate", "comparer", "action", "setter", "iterator"
	], true)).toArray();
	let defaultApis = Enumerable(fs.readdirSync(path.join(resources, common.defaultLang, 'apis'))).where(name => path.extname(name) === jsonExt).orderBy(element => path.basename(element, jsonExt)).toArray();
	// let defaultChanges = Enumerable(fs.readdirSync(path.join(resources, common.defaultLang, 'change'))).where(name => path.extname(name) === jsonExt).orderBy(element => path.basename(element, jsonExt), (element, other) => {
	// 	if (element === other) {
	// 		return 0;
	// 	} else if (common.isNewer(element, other)) {
	// 		return -1;
	// 	} else {
	// 		return 1;
	// 	}
	// }).toArray();
	let defaultChanges = Enumerable(fs.readdirSync(path.join(resources, common.defaultLang, 'change'))).where(name => path.extname(name) === jsonExt).orderBy(element => path.basename(element, jsonExt), Enumerable.comparers.less(common.isNewer)).toArray();

	common.versions = Enumerable.select(defaultChanges, change => path.basename(change, jsonExt)).toArray();
	fs.writeFileSync(path.join(resources, 'versions.json'), JSON.stringify(common.versions));

linq-js

use linq and lamdba in javascript

MIT
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis