本文整理汇总了TypeScript中ramda.pipe函数的典型用法代码示例。如果您正苦于以下问题:TypeScript pipe函数的具体用法?TypeScript pipe怎么用?TypeScript pipe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pipe函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1:
const composeQuery = (word: string) => {
const escapedWord = R.pipe(
R.toLower,
someSymbolsDelete,
R.trim,
fixDoubleSpaces,
someSymbolsToHyphens
)(word)
const dictionaryUrl = `https://www.ldoceonline.com/dictionary/${escapedWord}`
const queryUrl = `https://cors-anywhere.herokuapp.com/${dictionaryUrl}`
return queryUrl
}
开发者ID:yakhinvadim,项目名称:longman-to-anki,代码行数:15,代码来源:composeQuery.ts
示例2: splitBySelector
const extractDefinition = (senseMarkup: string) => {
const definitionNodeMarkup = splitBySelector({
selector: '.DEF',
onlyChildren: true
})(senseMarkup)[0]
if (!definitionNodeMarkup) {
return ''
}
const definition = R.pipe(
domify,
getTrimmedTextContent
)(definitionNodeMarkup)
return definition
}
开发者ID:yakhinvadim,项目名称:longman-to-anki,代码行数:17,代码来源:extractDefinition.ts
示例3: extractHeadword
const composeWordData = (pageMarkup: string) => {
const headword = extractHeadword(pageMarkup)
const pronunciation = extractPronunciation(pageMarkup)
const frequency = extractFrequency(pageMarkup)
const entries = R.pipe(
splitBySelector({ selector: '.ldoceEntry' }),
R.map(composeEntryData)
)(pageMarkup)
const wordData = {
headword,
pronunciation,
frequency,
entries
}
return wordData
}
开发者ID:yakhinvadim,项目名称:longman-to-anki,代码行数:18,代码来源:composeWordData.ts
示例4: clean
static clean(required, strings, floats, data) {
const rejectEmpty = R.reject(n => R.isEmpty(n[required]));
const cleanStrings = R.map(n => {
n[strings] = R.trim(n[strings]);
return n;
});
const cleanFloats = R.map(n => {
n[floats] = parseFloat(n[floats]);
return n;
});
const clean = R.pipe(rejectEmpty,
cleanStrings,
cleanFloats
);
return clean(data);
}
开发者ID:simbiosis-group,项目名称:ion2-helper,代码行数:20,代码来源:array-helper.ts
示例5: forEach
const doRequest = async axiosRequestConfig => {
axiosRequestConfig.headers = {
...headers,
...axiosRequestConfig.headers,
}
// add the request transforms
if (requestTransforms.length > 0) {
// overwrite our axios request with whatever our object looks like now
// axiosRequestConfig = doRequestTransforms(requestTransforms, axiosRequestConfig)
forEach(transform => transform(axiosRequestConfig), requestTransforms)
}
// add the async request transforms
if (asyncRequestTransforms.length > 0) {
for (let index = 0; index < asyncRequestTransforms.length; index++) {
const transform = asyncRequestTransforms[index](axiosRequestConfig)
if (isPromise(transform)) {
await transform
} else {
await transform(axiosRequestConfig)
}
}
}
// after the call, convert the axios response, then execute our monitors
const chain = pipe(
convertResponse(toNumber(new Date())),
// partial(convertResponse, [toNumber(new Date())]),
runMonitors,
)
return instance
.request(axiosRequestConfig)
.then(chain)
.catch(chain)
}
开发者ID:skellock,项目名称:apisauce,代码行数:37,代码来源:apisauce.ts
示例6: normalize
}
const replaceBrackets = (str: string) => str.replace(/[{[<]/g, '(').replace(/[}\]>]/g, ')');
const replaceOperators = (str: string) =>
str
.replace(/[|/]/g, OPERATORS.or)
.replace(/[;&]/g, OPERATORS.and)
.replace(/ plus /g, OPERATORS.and)
.replace(OPERATORS_REGEX, R.toLower);
export const normalize = R.pipe(
removeSpaceFromModule,
fixOperatorTypos,
insertPostFixAsStandalone,
convertCommas,
R.curry(convertToNumerals)(1),
replaceBrackets,
fixBrackets,
replaceOperators,
removeModuleTitles,
);
export default function normalizeString(string: string, moduleCode: ModuleCode): string {
// remove own module code from string (e.g. `CS1000R` would remove `CS1000R`, `CS1000`)
// @ts-ignore Strings are lists, damn it
const moduleWithoutPostfix = moduleCode.slice(0, R.findLastIndex(R.test(/\d/), moduleCode) + 1);
const moduleRegex = new RegExp(`\\b${moduleWithoutPostfix}(?:[A-Z]|[A-Z]R)?\\b`, 'g');
const preprocessed = string.replace(moduleRegex, '');
return normalize(preprocessed);
}
开发者ID:nusmodifications,项目名称:nusmods,代码行数:30,代码来源:normalizeString.ts
示例7:
const updateFromBootsrapMessage = (data: BootstrapMessage) =>
R.pipe<State, State, State>(
R.assoc('boards', data.boards),
R.assoc('notes', data.notes)
)
开发者ID:JamesHageman,项目名称:xstream-scrumbler,代码行数:5,代码来源:index.ts
示例8: pipe
import { pipe, curry } from 'ramda'
export const getRandom = (start, end) => start + Math.round(Math.random() * end)
export const jsonClone = pipe(
JSON.stringify,
JSON.parse
)
export const mutableAppend = curry((array, target) => {
target.splice(target.length, 0, ...array)
return target
})
开发者ID:NotBadDevs,项目名称:minesweepers,代码行数:13,代码来源:utils.ts
示例9: pipe
import * as sauce from 'reduxsauce';
import { pipe, replace, toUpper } from 'ramda';
const RX_CAPS = /(?!^)([A-Z])/g;
const camelToScreamingSnake = pipe(
replace(RX_CAPS, '_$1'),
toUpper
);
export const createReducer = sauce.createReducer;
export const createActions = (actions) => {
const { Creators: Actions } = sauce.createActions(actions);
Object.keys(actions).forEach((key) => {
Actions[key].toString = () => camelToScreamingSnake(key);
});
return Actions;
};
开发者ID:zanjs,项目名称:wxapp-typescript,代码行数:21,代码来源:createActions.ts
示例10: fn
);
const summaryFile = fs.createWriteStream(path.resolve(projectPath, 'SUMMARY.md'));
type ContentConverter = (c: string) => string;
const convertContentWith = R.curry(
(fn: ContentConverter, page: MarkdownPage) => R.merge(page, { content: fn(page.content) })
);
// string -> string
const convertionPineline = R.pipe(
addToSummary(summaryFile),
convertContentWith(decreaseHeaderLevel),
convertContentWith(convertImgTag),
convertContentWith(convertPlantUmlTag),
convertContentWith(removeToc),
convertContentWith(convertGist),
convertContentWith(convertSwagger),
addTitleAuthor,
);
// file -> void
// @ts-ignore waiting for @types/ramda update
const processMarkdown = R.pipeWith(R.then)([
(file: string) => inName(['README', 'SUMMARY'], file)
? Promise.resolve(file) : moveToIndex(file),
log('Convert'),
convert(convertionPineline)
]);
// dir -> void
开发者ID:aleung,项目名称:jekyll-to-gitbook,代码行数:32,代码来源:index.ts
注:本文中的ramda.pipe函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论