How to use realm-utils - 10 common examples

To help you get started, we’ve selected a few realm-utils 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 fuse-box / fuse-box / tests / _helpers / stubs / TestEnvironment.ts View on Github external
const randomName = `test-${new Date().getTime()}-${Math.random()}`;
	const root = path.join(appRoot.path, ".fusebox/old-tests/", randomName);
	const projectsHomeDir = path.join(root, "project");
	const modulesFolder = path.join(root, "modules");
	fsExtra.ensureDirSync(projectsHomeDir);
	fsExtra.ensureDirSync(modulesFolder);

	const serverOnly = opts.server === true;

	const output: any = {
		modules: {},
	};
	const scripts = [];

	// creating modules
	return each(opts.modules, (moduleParams, name) => {
		return new Promise((resolve, reject) => {
			moduleParams.homeDir = path.join(modulesFolder, name);
			moduleParams.output = path.join(modulesFolder, name, "dist/index.js");
			moduleParams.package = name;
			moduleParams.ensureTsConfig = false;
			moduleParams.cache = false;
			moduleParams.log = false;

			moduleParams.tsConfig = path.join(appRoot.path, "tests/_helpers/fixtures", "tsconfig.json");
			createFiles(moduleParams.homeDir, moduleParams.files);
			delete moduleParams.files;
			const fuse = FuseBox.init(moduleParams);
			fuse
				.bundle("index.js")
				.cache(false)
				.instructions(moduleParams.instructions);
github fuse-box / fuse-box / src / quantum / plugin / modifications / DynamicImportStatements.ts View on Github external
public static perform(core: QuantumCore, file: FileAbstraction): Promise {
		return each(file.dynamicImportStatements, (statement: RequireStatement) => {
			let target = statement.resolve();

			// if we can resolve a dynamic statements
			// that means that it could be technically mapped to a split bundle
			// or just resolved as it is
			if (target) {
				//console.log(target);
				target.canBeRemoved = false;

				if (!target.dependents.has(file)) {
					target.dependents.add(file);
				}
				const bit = new QuantumBit(target, statement);
				statement.isDynamicImport = true;
				target.quantumBitEntry = true;
				target.quantumBit = bit;
github fuse-box / fuse-box / src / quantum / plugin / QuantumCore.ts View on Github external
private async processCSS() {
		if (!this.opts.shouldGenerateCSS()) {
			return;
		}
		await each(this.producerAbstraction.bundleAbstractions, (bundleAbstraction: BundleAbstraction) => {
			return each(bundleAbstraction.packageAbstractions, (packageAbstraction: PackageAbstraction) => {
				return each(packageAbstraction.fileAbstractions, (fileAbstraction: FileAbstraction) => {
					// make sure that the files that were removed
					// during treeshake aren't grouped and processed
					if (!fileAbstraction.canBeRemoved) {
						return CSSModifications.perform(this, fileAbstraction);
					}
				});
			});
		});
	}
github fuse-box / fuse-box / src / plugins / vue / VuePlugin.ts View on Github external
styleFile.sourceMap,
								styleFile,
							);

							if (styleFile.cssDependencies) {
								styleFile.cssDependencies.forEach(path => {
									cache.styles[path] = 1;
								});
							}

							return styleFile;
						});
				}
			});

			await each(styleFiles, styleFile => {
				if (styleFile.alternativeContent) {
					concat.add(null, styleFile.alternativeContent);
				} else {
					// TODO: Do we need this anymore? Everything seems to work without?
					concat.add(
						null,
						`require('fuse-box-css')('${styleFile.info.fuseBoxPath}', ${JSON.stringify(styleFile.contents)})`,
						styleFile.sourceMap,
					);
				}
			});
		}

		if (file.context.useCache) {
			const hasGlobal = file.context.isGlobalyIgnored("process");
			const process = hasGlobal ? "global.process" : "process";
github fuse-box / fuse-box / src / quantum / plugin / modifications / ProcessEnvModification.ts View on Github external
public static perform(core: QuantumCore, file: FileAbstraction): Promise {
		if (core.opts.shouldReplaceProcessEnv()) {
			return each(file.processNodeEnv, (env: ReplaceableBlock) => {
				// working with conditional
				// removing dead code here
				if (env.isConditional) {
					env.handleActiveCode();
				} else {
					env.replaceWithValue();
				}
			});
		}
	}
}
github fuse-box / fuse-box / src / quantum / plugin / modifications / EnvironmentConditionModification.ts View on Github external
public static perform(core: QuantumCore, file: FileAbstraction) {
		// FuseBox.isServer

		return each(file.fuseboxIsEnvConditions, (replacable: ReplaceableBlock) => {
			if (core.opts.isTargetUniveral()) {
				if (replacable.identifier === "isServer") {
					replacable.setFunctionName(`${core.opts.quantumVariableName}.cs`);
				}
				if (replacable.identifier === "isBrowser") {
					replacable.setFunctionName(`${core.opts.quantumVariableName}.cb`);
				}
			} else {
				if (replacable.isConditional) {
					replacable.handleActiveCode();
				} else {
					replacable.replaceWithValue();
				}
			}
		});
	}
github fuse-box / fuse-box / src / plugins / ChainPlugin.ts View on Github external
public transform(file): Promise {
        // reduce? might it help here?
        // each resolves promises in a waterfall
        return each(this.plugins, (plugin) => {

            if (utils.isFunction(plugin.initialize)) {
                return plugin.initialize.apply(plugin, [file.context]);
            }
            if (utils.isFunction(plugin.transform)) {
                return plugin.transform.apply(plugin, [file]);
            }
        });
    }
github fuse-box / fuse-box / modules / fuse-test-reporter / index.js View on Github external
const $printStats = (data, took) => {
	if (cursor) {
		const amount = data.length;
		let totalTasks = 0;
		let failed = 0;
		let passed = 0;
		realm_utils_1.each(data, items => {
			realm_utils_1.each(items, (info, item) => {
				totalTasks += info.tasks.length;
				realm_utils_1.each(info.tasks, task => {
					if (task.data.success) {
						passed++;
					}
					if (task.data.error) {
						failed++;
					}
				});
			});
		});
		cursor.write("\n");
		cursor.write("   ☞ ");
		cursor.write("\n   ");
		cursor.green().write(` ${passed} passed `);
github fuse-box / fuse-box / src / sparky / SparkFlow.ts View on Github external
public exec() {
		return each(this.activities, (activity: any) => activity && activity()).then(() => {
			if (this.completedCallback) {
				this.completedCallback(this.files);
			}
			this.files = [];
		});
	}
}
github fuse-box / fuse-box / src / core / BundleProducer.ts View on Github external
public generateAbstraction(opts?: ProducerAbtractionOptions): Promise {
		const abstraction = new ProducerAbstraction(opts);

		return each(this.bundles, (bundle: Bundle) => {
			const bundleAbstraction = new BundleAbstraction(bundle.name);
			abstraction.registerBundleAbstraction(bundleAbstraction);
			return bundleAbstraction.parse(bundle.generatedCode.toString());
		}).then(() => {
			return abstraction;
		});
	}

realm-utils

Realm-js has a set of functionality that helps solving many problems or impediments related to Promises. Utilities live in this repository, apart from realm-js library. Typings included ### Install

ISC
Latest version published 7 years ago

Package Health Score

42 / 100
Full package analysis

Popular realm-utils functions

Similar packages