How to use linq-js - 10 common examples

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
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()) {
			let caption = defaultCaption;
			let captionPath = path.join(langPath, captionFile);
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));
github wm123450405 / linqjs / pack.js View on Github external
}
				for (let api of defaultApis) {
					let apiPath = path.join(apisPath, api);
					try {
						let apiContent = JSON.parse(fs.readFileSync(path.join(resources, common.defaultLang, 'apis', api)));
						if (fs.existsSync(apiPath)) {
							apiContent = extend(true, [], apiContent, JSON.parse(fs.readFileSync(apiPath)));
						}
						let since = apiContent.since || common.lastest, deprecated = apiContent.deprecated || common.newest;
						for (let method of (apiContent.methods || [])) {
							since = common.minVersion(Enumerable.min(common.histroys(method.histroys), histroy => histroy.since, common.versionComparer), since);
							deprecated = common.maxVersion(Enumerable.max(common.histroys(method.histroys), histroy => histroy.deprecated || common.lastest, common.versionComparer), deprecated);
						}
						for (let property of (apiContent.properties || [])) {
							since = common.minVersion(Enumerable.min(common.histroys(property.histroys), histroy => histroy.since, common.versionComparer), since);
							deprecated = common.maxVersion(Enumerable.max(common.histroys(property.histroys), histroy => histroy.deprecated || common.lastest, common.versionComparer), deprecated);
						}
						apis.children.push({
							code: path.basename(api, jsonExt),
							title: `${ apiContent.name || path.basename(api, jsonExt) } ${ common.capitalize(caption[apiContent.type]) }`,
							since: since,
							deprecated: deprecated
						});
					} catch(e) {
						console.error(e);
					}
				}
				directorys.splice(directorys.indexOf("apis"), 1, apis);

				fs.writeFileSync(path.join(langPath, directoryFile), JSON.stringify(directorys, null, '\t'));
				console.log(`Directory file for language ${ langName } is created`);
			}
github wm123450405 / linqjs / pack.js View on Github external
});
				}
				for (let api of defaultApis) {
					let apiPath = path.join(apisPath, api);
					try {
						let apiContent = JSON.parse(fs.readFileSync(path.join(resources, common.defaultLang, 'apis', api)));
						if (fs.existsSync(apiPath)) {
							apiContent = extend(true, [], apiContent, JSON.parse(fs.readFileSync(apiPath)));
						}
						let since = apiContent.since || common.lastest, deprecated = apiContent.deprecated || common.newest;
						for (let method of (apiContent.methods || [])) {
							since = common.minVersion(Enumerable.min(common.histroys(method.histroys), histroy => histroy.since, common.versionComparer), since);
							deprecated = common.maxVersion(Enumerable.max(common.histroys(method.histroys), histroy => histroy.deprecated || common.lastest, common.versionComparer), deprecated);
						}
						for (let property of (apiContent.properties || [])) {
							since = common.minVersion(Enumerable.min(common.histroys(property.histroys), histroy => histroy.since, common.versionComparer), since);
							deprecated = common.maxVersion(Enumerable.max(common.histroys(property.histroys), histroy => histroy.deprecated || common.lastest, common.versionComparer), deprecated);
						}
						apis.children.push({
							code: path.basename(api, jsonExt),
							title: `${ apiContent.name || path.basename(api, jsonExt) } ${ common.capitalize(caption[apiContent.type]) }`,
							since: since,
							deprecated: deprecated
						});
					} catch(e) {
						console.error(e);
					}
				}
				directorys.splice(directorys.indexOf("apis"), 1, apis);

				fs.writeFileSync(path.join(langPath, directoryFile), JSON.stringify(directorys, null, '\t'));
				console.log(`Directory file for language ${ langName } is created`);
github wm123450405 / linqjs / src / scripts / common.js View on Github external
isOlder(version, basaVersion) {
		let v = Enumerable.zip(asVersion(version || this.newest).split('.'), asVersion(basaVersion).split('.'), (ver, baseVer) => ({ ver, baseVer })).firstOrDefault({ ver: 0, baseVer: 0 }, v => v.ver !== v.baseVer);
		return parseInt(v.ver) >= parseInt(v.baseVer);
	},
	capitalize(value) {
github wm123450405 / linqjs / src / scripts / common.js View on Github external
get lastest() {
		return Enumerable.last(this.versions, version => !isPre.test(version));
	},
	get newest() {
github wm123450405 / linqjs / src / pages / index.vue View on Github external
}, () => {
                            delete Object.prototype.asEnumerable;
                            delete Array.prototype.asEnumerable;
                            delete String.prototype.asEnumerable;
                            delete Map.prototype.asEnumerable;
                            delete Set.prototype.asEnumerable;
                            Enumerable.config.extends.array = false;
                        }, () => {
                            delete Object.prototype.asEnumerable;
github wm123450405 / linqjs / src / scripts / common.js View on Github external
maxVersion(...versions) {
		return Enumerable.max(versions, '', this.versionComparer);
	},
	minVersion(...versions) {
github wm123450405 / linqjs / src / scripts / common.js View on Github external
minVersion(...versions) {
		return Enumerable.min(versions, '', this.versionComparer);
	},
	isNewer(version, basaVersion) {

linq-js

use linq and lamdba in javascript

MIT
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis