ramda#difference TypeScript Examples
The following examples show how to use
ramda#difference.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.ts From reskript with MIT License | 7 votes |
drawFeatureMatrix = (projectSettings: ProjectSettings, only?: string): void => {
const buildTargets = only
? [only]
: difference(Object.keys(projectSettings.featureMatrix), projectSettings.build.excludeFeatures);
const headers: Column[] = [
{value: '', align: 'left'},
...buildTargets.map(target => ({value: target})),
];
const featureNames = Object.keys(Object.values(projectSettings.featureMatrix)[0]);
if (isEmpty(featureNames)) {
return;
}
const nameToValues = (name: string): string[] => [
name,
...buildTargets.map(target => projectSettings.featureMatrix[target][name]).map(printableValue),
];
const rows = featureNames.map(nameToValues);
const table = new ConsoleTable(headers, rows);
logger.log(table.render());
}
Example #2
Source File: useNextQuestion.tsx From nosgestesclimat-site with MIT License | 5 votes |
export function getNextQuestions(
missingVariables: Array<MissingVariables>,
questionConfig: SimulationConfig['questions'] = {},
answeredQuestions: Array<DottedName> = [],
situation: Simulation['situation'] = {},
engine: Engine
): Array<DottedName> {
const {
'non prioritaires': notPriority = [],
liste: whitelist = [],
'liste noire': blacklist = [],
} = questionConfig
let nextSteps = difference(getNextSteps(missingVariables), answeredQuestions)
nextSteps = nextSteps.filter(
(step) =>
(!whitelist.length || whitelist.some((name) => step.startsWith(name))) &&
(!blacklist.length || !blacklist.some((name) => step.startsWith(name)))
)
const nextQuestions = nextSteps.filter((name) => {
const rule = engine.getRule(name)
return rule.rawNode.question != null
})
const lastStep = last(answeredQuestions)
// L'ajout de la réponse permet de traiter les questions dont la réponse est
// "une possibilité", exemple "contrat salarié . cdd"
const lastStepWithAnswer =
lastStep && situation[lastStep]
? ([lastStep, situation[lastStep]]
.join(' . ')
.replace(/'/g, '')
.trim() as DottedName)
: lastStep
return sortBy((question) => {
const indexList =
whitelist.findIndex((name) => question.startsWith(name)) + 1
const indexNotPriority =
notPriority.findIndex((name) => question.startsWith(name)) + 1
const differenceCoeff = questionDifference(question, lastStepWithAnswer)
return indexList + indexNotPriority + differenceCoeff
}, nextQuestions)
}
Example #3
Source File: index.ts From reskript with MIT License | 5 votes |
run = async (cmd: BuildCommandLineArgs): Promise<void> => {
const {cwd, mode, clean, configFile} = cmd;
process.env.NODE_ENV = mode;
await prepareEnvironment(cwd, mode);
if (cmd.analyze && !cmd.buildTarget) {
logger.error('--analyze must be used with --build-target to specify only one target');
process.exit(21);
}
const projectSettings = await readProjectSettings({commandName: 'build', specifiedFile: configFile, ...cmd});
const featureNames = difference(Object.keys(projectSettings.featureMatrix), projectSettings.build.excludeFeatures);
validateFeatureNames(featureNames, cmd.featureOnly);
validateProjectSettings(projectSettings);
await strictCheckRequiredDependency(projectSettings, cwd);
drawFeatureMatrix(projectSettings, cmd.featureOnly);
if (clean) {
await fs.rm(path.join(cwd, 'dist'), {recursive: true, force: true});
}
const featureNamesToUse = cmd.featureOnly ? [cmd.featureOnly] : featureNames;
const entryLocation: EntryLocation = {
cwd: cmd.cwd,
srcDirectory: cmd.srcDirectory,
entryDirectory: cmd.entriesDirectory,
only: cmd.entriesOnly,
};
if (projectSettings.driver === 'webpack') {
const importing = [import('@reskript/config-webpack'), import('./webpack/index.js')] as const;
const [{collectEntries}, {build}] = await Promise.all(importing);
const entries = await collectEntries(entryLocation);
const createBuildContext = await createBuildContextWith({cmd, projectSettings, entries});
await build({cmd, projectSettings, buildContextList: featureNamesToUse.map(createBuildContext)});
}
else {
const importing = [import('@reskript/config-vite'), import('./vite/index.js')] as const;
const [{collectEntries}, {build}] = await Promise.all(importing);
const entries = await collectEntries(entryLocation);
const createBuildContext = await createBuildContextWith({cmd, projectSettings, entries});
await build({cmd, projectSettings, buildContextList: featureNamesToUse.map(createBuildContext)});
}
}