How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • const anymatch = require('anymatch');
    
    const matchers = [ 'path/to/file.js', 'path/anyjs/**/*.js', /foo.js$/, string => string.includes('bar') && string.length > 10 ] ;
    
    anymatch(matchers, 'path/to/file.js'); // true
    anymatch(matchers, 'path/anyjs/baz.js'); // true
    anymatch(matchers, 'path/to/foo.js'); // true
    anymatch(matchers, 'path/to/bar.js'); // true
    anymatch(matchers, 'bar.js'); // false
    
    // returnIndex = true
    anymatch(matchers, 'foo.js', {returnIndex: true}); // 2
    anymatch(matchers, 'path/anyjs/foo.js', {returnIndex: true}); // 1
    
    // any picomatc
    
    // using globs to match directories and their children
    anymatch('node_modules', 'node_modules'); // true
    anymatch('node_modules', 'node_modules/somelib/index.js'); // false
    anymatch('node_modules/**', 'node_modules/somelib/index.js'); // true
    anymatch('node_modules/**', '/absolute/path/to/node_modules/somelib/index.js'); // false
    anymatch('**/node_modules/**', '/absolute/path/to/node_modules/somelib/index.js'); // true
    
    const matcher = anymatch(matchers);
    ['foo.js', 'bar.js'].filter(matcher);  // [ 'foo.js' ]
    anymatch master*
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">import</span> anymatch</code></pre>
    Docs
    0
  • constructor(config) {
        
        //...
    // This can"t be true when compiling this way.
    
        delete this.options.moduleResolution;
    
        this.options.sourceMap = !!config.sourceMaps;
        this.isIgnored = anymatch(options.ignore || config.conventions.vendor);
        if (this.options.pattern) {
          this.pattern = this.options.pattern;
          delete this.options.pattern;
        }
    
        
    
        //...
    }
    
      
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript">constructor <span class="token function">TypeScriptCompiler</span><span class="token punctuation">(</span>config<span class="token operator">:</span> <span class="token builtin">any</span><span class="token punctuation">)</span><span class="token operator">:</span> TypeScriptCompiler</code></pre>
    /brunch/typescript-brunch mit
    0
  • constructor(config) {
        
        //...
    opts.sourceMaps = !!config.sourceMaps;
    
        if (opts.pattern) {
          this.pattern = opts.pattern;
          delete opts.pattern;
        }
    
        this.isIgnored = anymatch(options.ignore || /^(bower_components|vendor)/);
        this.options = opts;
      }
    
      
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript">constructor <span class="token function">BabelCompiler</span><span class="token punctuation">(</span>config<span class="token operator">:</span> <span class="token builtin">any</span><span class="token punctuation">)</span><span class="token operator">:</span> BabelCompiler</code></pre>
    /babel/babel-brunch isc
    0
  • history.forEach(update => {
        if (anymatch(view.filePattern, update.path)) {
          updates[update.path] = update
        }
      })
    
      
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>local <span class="token keyword">var</span><span class="token punctuation">)</span> history<span class="token operator">:</span> <span class="token builtin">any</span></code></pre>
    /beakerbrowser/dat-archive-map-reduce mit
    0
  • onCompile(changedFiles) {
        const enabled = this.enabled;
        const conns = this.connections;
        if (!enabled) return;
    
        const didCompile = changedFiles.length > 0;
        const isCss = file => anymatch(this.cssMatch, file.path);
        const isJs = file => anymatch(this.jsMatch, file.path);
        const isJsOrCss = file => isJs(file) || isCss(file);
    
        const allCss = didCompile && changedFiles.every(isCss);
        const allJs = this.hot && didCompile && changedFiles.every(isJs);
        
        //...
    }
    
      
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>method<span class="token punctuation">)</span> AutoReloader<span class="token punctuation">.</span><span class="token function">onCompile</span><span class="token punctuation">(</span>changedFiles<span class="token operator">:</span> <span class="token builtin">any</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token keyword">void</span></code></pre>
    /brunch/auto-reload-brunch MIT
    0
  • getAsset(name, state) {
        const manifest = this.resource && this.resource.manifest || {};
        const deps = manifest.deps || {};
        const res = deps[name] || {};
        return {
          js: res.js || [],
          css: res.css || [],
          state: serialize(state || {}, { isJSON: true }),
        };
      }
    
      
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>method<span class="token punctuation">)</span> Engine<span class="token punctuation">.</span><span class="token function">getAsset</span><span class="token punctuation">(</span>name<span class="token operator">:</span> <span class="token builtin">any</span><span class="token punctuation">,</span> state<span class="token operator">:</span> <span class="token builtin">any</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token punctuation">{</span> js<span class="token operator">:</span> <span class="token builtin">any</span><span class="token punctuation">;</span> css<span class="token operator">:</span> <span class="token builtin">any</span><span class="token punctuation">;</span> state<span class="token operator">:</span> <span class="token builtin">string</span><span class="token punctuation">;</span> <span class="token punctuation">}</span></code></pre>
    /easy-team/egg-view-react-ssr MIT
    0
  • serialize({
        haxorXSS: '</script>'
    });
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token builtin">any</span></code></pre>
    Docs
    0
  • module.exports = View.extend(templater).extend({
      
      //...
    ,
    
      templateContext: function () {
        
        //...
    var serializedModel = serialize(this.model.toJSON(), { isJSON: true });
    
        
    
        //...
    }
    
    })
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">module</span> <span class="token keyword">export</span><span class="token operator">=</span> <span class="token punctuation">(</span>property<span class="token punctuation">)</span> <span class="token keyword">export</span><span class="token operator">=</span><span class="token operator">:</span> <span class="token builtin">any</span></code><div class="typing-tooltip-markup">Renders a page in GOV.UK style using govuk<em>template. Does not use jsdom itself but renders template directly because jsdom does not seem to play nicely with <script> tags.</em></div></pre>
    /alphagov/spotlight mit
    0
  • function buildEmbeddedCode(data, webpackAssets) {
      
      //...
    return `
        <script>
          (function() {
            var namespace = '${buildConst.namespace}';
            var pkg = '${buildConst.pkgName}';
            if (typeof window != 'undefined') {
              if (!window.hasOwnProperty(namespace)) {
                window[namespace] = {};
              }
              if (window[namespace] && !window[namespace].hasOwnProperty(pkg)) {
                window[namespace][pkg] = [];
              }
              if (Array.isArray(window[namespace][pkg])) {
                var data = ${serialize(dataWithUuid)};
                window[namespace][pkg].push(data);
              }
            }
          })()
        </script>
        <div id=${uuid}></div>
        ${_.map(chunks, chunk => {
          
          //...
    }).join('')}
        ${_.map(bundles, bundle => {
          
          //...
    }).join('')}
      `
    }
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">function</span> <span class="token function">buildEmbeddedCode</span><span class="token punctuation">(</span><span class="token parameter">data<span class="token operator">:</span> <span class="token punctuation">{</span> chapters<span class="token operator">:</span> any<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span> embeddedItems<span class="token operator">:</span> any<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span> isFullWidth<span class="token operator">:</span> boolean<span class="token punctuation">;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> webpackAssets<span class="token operator">:</span> <span class="token punctuation">{</span> chunks<span class="token operator">:</span> string<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span> bundles<span class="token operator">:</span> string<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token punctuation">}</span></span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token builtin">string</span></code><div class="typing-tooltip-markup"><em>@export</em><br><br><em>@param</em> <code>data</code> — Data for Dual Channel Root React Component<br><br><em>@param</em> <code>webpackAssets</code> — webpack bundles and chunks<br><br><em>@returns</em> — embedded code</div></pre>
    /twreporter/orangutan-monorepo mit
    0
  • serialize(obj, {space: 2});
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token builtin">any</span></code></pre>
    Docs
    0
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples