How to use ramda-extension - 10 common examples

To help you get started, we’ve selected a few ramda-extension 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 lundegaard / redux-tools / packages / injectors-react / src / makeHook.js View on Github external
const makeHook = storeInterface => {
	invariant(isObject(storeInterface), 'The store interface is undefined.');

	const { getEntries, ejectionKey, injectionKey, type } = storeInterface;

	const pascalCaseType = toPascalCase(type);
	const hookName = `use${pascalCaseType}`;

	const useInjectables = (injectables, options = {}) => {
		const injectableKeys = keys(injectables);

		const locationMessage =
			`@redux-tools: This warning happened while injecting the following ${type}: ` +
			`${injectableKeys}.`;

		const warn = (...args) => console.warn(locationMessage, ...args);

		// NOTE: `options.global` and `options.persist` are deprecated.
github lundegaard / redux-tools / packages / injectors-react / src / makeHook.js View on Github external
const makeHook = storeInterface => {
	invariant(isObject(storeInterface), 'The store interface is undefined.');

	const { getEntries, ejectionKey, injectionKey, type } = storeInterface;

	const pascalCaseType = toPascalCase(type);
	const hookName = `use${pascalCaseType}`;

	const useInjectables = (injectables, options = {}) => {
		const injectableKeys = keys(injectables);

		const locationMessage =
			`@redux-tools: This warning happened while injecting the following ${type}: ` +
			`${injectableKeys}.`;

		const warn = (...args) => console.warn(locationMessage, ...args);

		// NOTE: `options.global` and `options.persist` are deprecated.
		const isGlobal = options.isGlobal || options.global || false;
		const isPersistent = options.isPersistent || options.persist || false;
		const feature = options.feature || DEFAULT_FEATURE;
		const contextNamespace = useNamespace(feature);
github lundegaard / redux-tools / packages / injectors / src / enhanceStore.js View on Github external
const enhanceStore = (prevStore, storeInterface, { onEjected = noop, onInjected = noop } = {}) => {
	invariant(
		isObject(prevStore),
		'You must pass a Redux store as the first argument to `enhanceStore()`'
	);

	invariant(
		isObject(storeInterface),
		'You must pass a store interface as the second argument to `enhanceStore()`'
	);

	const { injectionKey, ejectionKey, getEntries, setEntries, type } = storeInterface;
	const { dispatch = noop } = prevStore;
	const actionType = toScreamingSnakeCase(type);

	const inject = (injectables, props = {}) => {
		const entries = createEntries(injectables, props);

		forEach(
			entry =>
				invariant(
					// NOTE: `isFunction` from ramda-extension returns `false` for `jest.fn()`.
					typeof entry.value === 'function',
					`Injecting ${type}, but the value of ${JSON.stringify(entry)} is not a function.`
github lundegaard / react-union / rollup.config.js View on Github external
'hoist-non-react-statics': 'HoistNonReactStatics',
	'prop-types': 'PropTypes',
	ramda: 'R',
	'ramda-extension': 'R_',
	react: 'React',
	'react-dom': 'ReactDOM',
	'react-union': 'ReactUnion',
};

// eslint-disable-next-line import/no-dynamic-require
const pkg = require(path.join(PACKAGE_ROOT_PATH, 'package.json'));
const dependencies = [...keys(pkg.dependencies), ...keys(pkg.peerDependencies)];

const external = id => dependencies.includes(id) || id.includes('@babel/runtime');

const globalName = toPascalCase(LERNA_PACKAGE_NAME);
const fileName = toKebabCase(LERNA_PACKAGE_NAME);

const umdExternal = ['react', 'react-dom', 'ramda', 'ramda-extension', 'prop-types'];

export default [
	// CJS
	{
		input: INPUT_FILE,
		external,
		output: {
			file: path.join(PACKAGE_ROOT_PATH, 'lib', `${fileName}.js`),
			format: 'cjs',
			indent: false,
		},
		plugins: [plugins.babel, plugins.cjs],
	},
github lundegaard / react-union / packages / react-union-scripts / scripts / startDevServer.js View on Github external
const getProxyMiddleware = ({ proxy } = {}) => {
	if (!proxy) {
		return [];
	}
	let normalizedConfig = proxy;
	if (!R_.isArray(proxy)) {
		normalizedConfig = R.pipe(
			R.mapObjIndexed((target, context) => {
				// for more info see https://github.com/webpack/webpack-dev-server/blob/master/lib/Server.js#L193
				const correctedContext = R.o(R.replace(/\/\*$/, ''), R.replace(/^\*$/, '**'))(context);
				if (R_.isString(target)) {
					return {
						context: correctedContext,
						target,
					};
				} else {
					return {
						...target,
						context: correctedContext,
					};
				}
			}),
github lundegaard / react-union / packages / react-union-scripts / scripts / lib / middleware.js View on Github external
const proxyMiddleware = ({ proxy } = {}) => {
	if (!proxy) {
		return [];
	}
	let normalizedConfig = proxy;
	if (!isArray(proxy)) {
		normalizedConfig = pipe(
			mapObjIndexed((target, context) => {
				// for more info see https://github.com/webpack/webpack-dev-server/blob/master/lib/Server.js#L193
				const correctedContext = o(replace(/\/\*$/, ''), replace(/^\*$/, '**'))(context);
				if (isString(target)) {
					return {
						context: correctedContext,
						target,
					};
				} else {
					return {
						...target,
						context: correctedContext,
					};
				}
			}),
github lundegaard / react-union / packages / react-union-scripts / scripts / startDevServer.js View on Github external
R.mapObjIndexed((target, context) => {
				// for more info see https://github.com/webpack/webpack-dev-server/blob/master/lib/Server.js#L193
				const correctedContext = R.o(R.replace(/\/\*$/, ''), R.replace(/^\*$/, '**'))(context);
				if (R_.isString(target)) {
					return {
						context: correctedContext,
						target,
					};
				} else {
					return {
						...target,
						context: correctedContext,
					};
				}
			}),
			R.values
github lundegaard / react-union / packages / react-union-scripts / scripts / lib / middleware.js View on Github external
mapObjIndexed((target, context) => {
				// for more info see https://github.com/webpack/webpack-dev-server/blob/master/lib/Server.js#L193
				const correctedContext = o(replace(/\/\*$/, ''), replace(/^\*$/, '**'))(context);
				if (isString(target)) {
					return {
						context: correctedContext,
						target,
					};
				} else {
					return {
						...target,
						context: correctedContext,
					};
				}
			}),
			values
github lundegaard / react-union / packages / react-union-scripts / scripts / lib / utils.js View on Github external
/**
 * Converts the passed config to normalized shape.
 *
 * @example
 *
 * 		normalizeConfig(["app", { name: "app2" }]) // [{ name: "app" }, { name: "app2" }]
 *
 * 		normalizeConfig({ templateFilename: 'index.ejs', apps: ["app"]})
 * 		// [{ name: "app", templateFilename: 'index.ejs', }]
 *
 * @see tests
 */
const normalizeConfig = R.cond([
	[R_.isArray, fromArrayConfig_],
	[R_.isObject, fromObjectConfig_],
	[R.T, R_.noop],
]);

const getAppPattern_ = R.path(['workspaces', 'appPattern']);

const setAppsIfMissing_ = config => {
	const uniRepoDirs = () => utilsFs.readDirs(DEFAULT_UNI_REPO_APP_DIR);
	const appsPattern = getAppPattern_(config) || getAppPattern_(DEFAULT_UNION_CONFIG);
	const appDirs = isMonoRepo ? utilsFs.readAllAppsFromWorkspaces(appsPattern) : uniRepoDirs();
	return R.cond([
		[nilOrEmpty_, R.always(appDirs)],
		[R_.isArray, R.identity],
		[c => !c.apps, c => R.mergeDeepRight(c, { apps: appDirs })],
		[R.T, R.identity],
	])(config);
};
github lundegaard / react-union / packages / react-union-scripts / scripts / lib / cli.js View on Github external
* 			[
 * 				"node",
 * 				"node/process-2.js",
 * 				"--app",
 * 				"AppName"
 * 			]
 * 		) // "AppName"
 */
const getArgValue = (arg, program) =>
	compose(
		ifElse(equals(-1), always(null), x => program[x + 1]),
		findIndex(equals(arg))
	)(program);

const program = process.argv;
const programIncludes = includes(program);
const programNotInclude = notInclude(program);

/** optimize for development */
const debug = programNotInclude('--release');

/** level of debugging messages */
const verbose = programIncludes('--verbose');

/** if true, create proxy */
const proxy = programIncludes('--proxy');

/** if true, do not suport HMR */
const noHMR = programIncludes('--no-hmr');

/** if true, do not do anything SSR related */
const noSSR = programIncludes('--no-ssr');