How to use compose-function - 10 common examples

To help you get started, we’ve selected a few compose-function 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 vorpaljs / bash-parser / packages / bash-parser / src / modes / posix / rules / function-name.js View on Github external
export default function functionName() {
	return compose(map((tk, idx, iterable) => {
		// apply only on valid positions
		// (start of simple commands)
		// if token can form the name of a function,
		// type of token is changed from WORD to NAME

		/* console.log(
			tk._.maybeStartOfSimpleCommand,
			tk.is('WORD'),
			iterable.ahead(1) &&
				iterable.ahead(1).is('OPEN_PAREN'),
			iterable.ahead(2) &&
				iterable.ahead(2).is('CLOSE_PAREN')
		);*/

		if (
			tk._.maybeStartOfSimpleCommand &&
github tinajs / mina-webpack / packages / mina-entry-webpack-plugin / src / index.ts View on Github external
// generte request
    let request: string
    if (isClassical) {
      request = `!${minaLoader}?${JSON.stringify(
        minaLoaderOptions
      )}!${virtualMinaLoader}?${JSON.stringify({
        extensions,
      })}!${relativeRealRequest}`
    } else {
      request = relativeRealRequest
    }

    // entry name for SingleEntryPlugin
    // `../../path/to/comp` => `_/_/path/to/comp`
    const name = compose(
      ensurePosix,
      // FIXME: replace-ext will remove the leading `./` in path
      // see https://github.com/gulpjs/replace-ext/issues/5
      path => replaceExt(path, '.js'),
      urlToRequest,
      toSafeOutputPath
    )(relativeRealPath)

    // skip existing entries
    const existingEntry = entries.find(item => item.request === request)
    if (existingEntry) {
      if (parentEntry) {
        existingEntry.parents.push(parentEntry)
      }
      return
    }
github tinajs / mina-webpack / packages / mina-loader / src / loaders / mina.ts View on Github external
const originalRequest = loaderUtils.getRemainingRequest(this)
  const filePath = this.resourcePath

  let relativePath = path.relative(this.rootContext, filePath)

  // move some files into subpackages
  // .js files are moved in entry plugin but .json/.wxss/.wxml should be handled here
  // @ts-ignore
  const subpackageMapping: Record = this.subpackageMapping || {}
  const entryName = replaceExt(helpers.toSafeOutputPath(relativePath), '')
  if (subpackageMapping[entryName]) {
    relativePath = subpackageMapping[entryName] + '.mina'
  }

  const dirname = compose(
    ensurePosix,
    helpers.toSafeOutputPath,
    path.dirname
  )(relativePath)

  getBlocks(this, originalRequest)
    .then(blocks =>
      Promise.all(
        [...TAGS_FOR_FILE_LOADER, ...TAGS_FOR_OUTPUT].map(async (tag: Tag) => {
          let result: BlockResult = {
            tag,
            content: DEFAULT_CONTENT_OF_TAG[tag],
          }

          if (
            !blocks[tag] ||
github stoeffel / underscore.string.fp / index.js View on Github external
//  Underscore.string
//  (c) 2010 Esa-Matti Suuronen 
//  Underscore.string is freely distributable under the terms of the MIT license.
//  Documentation: https://github.com/epeli/underscore.string
//  Some code is borrowed from MooTools and Alexandru Marasteanu.
//  Version '1.0.4'

'use strict';

var S = require('compose-function');

S.VERSION = '1.0.4';

S.isBlank          = require('./isBlank');
S.stripTags        = require('./stripTags');
S.capitalize       = require('./capitalize');
S.decapitalize     = require('./decapitalize');
S.chop             = require('./chop');
S.trim             = require('./trim');
S.clean            = require('./clean');
S.count            = require('./count');
S.chars            = require('./chars');
S.swapCase         = require('./swapCase');
S.escapeHTML       = require('./escapeHTML');
S.unescapeHTML     = require('./unescapeHTML');
S.splice           = require('./splice');
S.insert           = require('./insert');
S.replaceAll       = require('./replaceAll');
github stoeffel / underscore.string.fp / index.js View on Github external
S.levenshtein      = require('./levenshtein');
S.toBoolean        = require('./toBoolean');
S.exports          = require('./exports');
S.escapeRegExp     = require('./escapeRegExp');

// Aliases
S.strip     = S.trim;
S.lstrip    = S.ltrim;
S.rstrip    = S.rtrim;
S.center    = S.lrpad;
S.rjust     = S.lpad;
S.ljust     = S.rpad;
S.contains  = S.include;
S.q         = S.quote;
S.toBool    = S.toBoolean;
S.camelcase = S.camelize;

module.exports = S;
github stoeffel / underscore.string.fp / index.js View on Github external
//  Underscore.string
//  (c) 2010 Esa-Matti Suuronen 
//  Underscore.string is freely distributable under the terms of the MIT license.
//  Documentation: https://github.com/epeli/underscore.string
//  Some code is borrowed from MooTools and Alexandru Marasteanu.
//  Version '1.0.4'

'use strict';

var S = require('compose-function');

S.VERSION = '1.0.4';

S.isBlank          = require('./isBlank');
S.stripTags        = require('./stripTags');
S.capitalize       = require('./capitalize');
S.decapitalize     = require('./decapitalize');
S.chop             = require('./chop');
S.trim             = require('./trim');
S.clean            = require('./clean');
S.count            = require('./count');
S.chars            = require('./chars');
S.swapCase         = require('./swapCase');
S.escapeHTML       = require('./escapeHTML');
S.unescapeHTML     = require('./unescapeHTML');
S.splice           = require('./splice');
S.insert           = require('./insert');
S.replaceAll       = require('./replaceAll');
S.replaceAllIgnoreCase       = require('./replaceAllIgnoreCase');
S.include          = require('./include');
S.join             = require('./join');
S.lines            = require('./lines');
github stoeffel / underscore.string.fp / index.js View on Github external
S.slugify          = require('./slugify');
S.surround         = require('./surround');
S.quote            = require('./quote');
S.unquote          = require('./unquote');
S.repeat           = require('./repeat');
S.naturalCmp       = require('./naturalCmp');
S.levenshtein      = require('./levenshtein');
S.toBoolean        = require('./toBoolean');
S.exports          = require('./exports');
S.escapeRegExp     = require('./escapeRegExp');

// Aliases
S.strip     = S.trim;
S.lstrip    = S.ltrim;
S.rstrip    = S.rtrim;
S.center    = S.lrpad;
S.rjust     = S.lpad;
S.ljust     = S.rpad;
S.contains  = S.include;
S.q         = S.quote;
S.toBool    = S.toBoolean;
S.camelcase = S.camelize;

module.exports = S;
github stoeffel / underscore.string.fp / index.js View on Github external
//  Underscore.string is freely distributable under the terms of the MIT license.
//  Documentation: https://github.com/epeli/underscore.string
//  Some code is borrowed from MooTools and Alexandru Marasteanu.
//  Version '1.0.4'

'use strict';

var S = require('compose-function');

S.VERSION = '1.0.4';

S.isBlank          = require('./isBlank');
S.stripTags        = require('./stripTags');
S.capitalize       = require('./capitalize');
S.decapitalize     = require('./decapitalize');
S.chop             = require('./chop');
S.trim             = require('./trim');
S.clean            = require('./clean');
S.count            = require('./count');
S.chars            = require('./chars');
S.swapCase         = require('./swapCase');
S.escapeHTML       = require('./escapeHTML');
S.unescapeHTML     = require('./unescapeHTML');
S.splice           = require('./splice');
S.insert           = require('./insert');
S.replaceAll       = require('./replaceAll');
S.replaceAllIgnoreCase       = require('./replaceAllIgnoreCase');
S.include          = require('./include');
S.join             = require('./join');
S.lines            = require('./lines');
S.dedent           = require('./dedent');
S.dedentPattern    = require('./dedentPattern');
github stoeffel / underscore.string.fp / index.js View on Github external
//  Some code is borrowed from MooTools and Alexandru Marasteanu.
//  Version '1.0.4'

'use strict';

var S = require('compose-function');

S.VERSION = '1.0.4';

S.isBlank          = require('./isBlank');
S.stripTags        = require('./stripTags');
S.capitalize       = require('./capitalize');
S.decapitalize     = require('./decapitalize');
S.chop             = require('./chop');
S.trim             = require('./trim');
S.clean            = require('./clean');
S.count            = require('./count');
S.chars            = require('./chars');
S.swapCase         = require('./swapCase');
S.escapeHTML       = require('./escapeHTML');
S.unescapeHTML     = require('./unescapeHTML');
S.splice           = require('./splice');
S.insert           = require('./insert');
S.replaceAll       = require('./replaceAll');
S.replaceAllIgnoreCase       = require('./replaceAllIgnoreCase');
S.include          = require('./include');
S.join             = require('./join');
S.lines            = require('./lines');
S.dedent           = require('./dedent');
S.dedentPattern    = require('./dedentPattern');
S.reverse          = require('./reverse');
S.startsWith       = require('./startsWith');
github stoeffel / underscore.string.fp / index.js View on Github external
S.unquote          = require('./unquote');
S.repeat           = require('./repeat');
S.naturalCmp       = require('./naturalCmp');
S.levenshtein      = require('./levenshtein');
S.toBoolean        = require('./toBoolean');
S.exports          = require('./exports');
S.escapeRegExp     = require('./escapeRegExp');

// Aliases
S.strip     = S.trim;
S.lstrip    = S.ltrim;
S.rstrip    = S.rtrim;
S.center    = S.lrpad;
S.rjust     = S.lpad;
S.ljust     = S.rpad;
S.contains  = S.include;
S.q         = S.quote;
S.toBool    = S.toBoolean;
S.camelcase = S.camelize;

module.exports = S;