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

  • var chalk = require('chalk');
     
    var str = chalk.bold.red('foo') + ' bar';
    console.log('[ANSI]', str)
    console.log('[HTML]', ansiHTML(str));
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">import</span> chalk</code></pre>
    Docs
    1
  • var ansiHTML = require('ansi-html');
    var str = ansiHTML('[ANSI_TEXT]');
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">function</span> <span class="token function">ansiHTML</span><span class="token punctuation">(</span><span class="token parameter">text<span class="token operator">:</span> string</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token function">any</span> <span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">module</span> ansiHTML <span class="token keyword">import</span> ansiHTML</code><div class="typing-tooltip-markup">Converts text with ANSI color codes to HTML markup.<br><br><em>@param</em> <code>text</code><br><br><em>@returns</em></div></pre>
    Docs
    0
  • ansiHTML.reset();
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token builtin">any</span></code></pre>
    Docs
    0
  • ansiHTML.setColors({
      reset: ['555', '666'], // FOREGROUND-COLOR or [FOREGROUND-COLOR] or [, BACKGROUND-COLOR] or [FOREGROUND-COLOR, BACKGROUND-COLOR]
    // FOREGROUND-COLOR or [FOREGROUND-COLOR] or [, BACKGROUND-COLOR] or [FOREGROUND-COLOR, BACKGROUND-COLOR]
      black: 'aaa',	// String
    // String
      red: 'bbb',
      green: 'ccc',
      yellow: 'ddd',
      blue: 'eee',
      magenta: 'fff',
      cyan: '999',
      lightgrey: '888',
      darkgrey: '777'
    });
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token builtin">any</span></code></pre>
    Docs
    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
  • var serialize = require('serialize-javascript');
    
    serialize({
        str  : 'string',
        num  : 0,
        obj  : {foo: 'foo'},
        arr  : [1, 2, 3],
        bool : true,
        nil  : null,
        undef: undefined,
        inf  : Infinity,
        date : new Date("Thu, 28 Apr 2016 22:02:17 GMT"),
        map  : new Map([['hello', 'world']]),
        set  : new Set([123, 456]),
        fn   : function echo(arg) { return arg; },
        re   : /([^\s]+)/g,
        big  : BigInt(10),
    });
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">function</span> <span class="token function">serialize</span><span class="token punctuation">(</span><span class="token parameter">input<span class="token operator">:</span> any<span class="token punctuation">,</span> options<span class="token operator">?</span><span class="token operator">:</span> serializeJavascript<span class="token punctuation">.</span>SerializeJSOptions <span class="token operator">|</span> number <span class="token operator">|</span> string</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token function">string</span> <span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">namespace</span> serialize <span class="token keyword">import</span> serialize</code><div class="typing-tooltip-markup">Serialize JavaScript to a superset of JSON that includes regular expressions and functions.<br><br><em>@param</em> <code>input</code> — data to serialize<br><br><em>@param</em> <code>options</code> — optional object<br><br><em>@returns</em> — serialized data</div></pre>
    Docs
    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 search(data, {
      locale,
      format = formatResults(locale), // length format
      label,
      query = "", // initial search query
      placeholder = "Search", // placeholder text to show when empty
      columns = maybeColumns(data),
      spellcheck,
      autocomplete,
      autocapitalize,
      filter = columns === undefined ? searchFilter : columnFilter(columns), // returns the filter function given query
      datalist,
      disabled,
      required = true, // if true, the value is everything if nothing is selected
      width
    } = {}) {
      
      //...
    const input = html`<input
        name=input
        type=search
        list=${listId}
        disabled=${disabled}
        spellcheck=${truefalse(spellcheck)}
        autocomplete=${onoff(autocomplete)}
        autocapitalize=${onoff(autocapitalize)}
        placeholder=${placeholder}
        value=${query}
        oninput=${oninput}
      >`;
      
      //...
    }
    
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">function</span> <span class="token function">search</span><span class="token punctuation">(</span><span class="token parameter">data<span class="token operator">:</span> any<span class="token punctuation">,</span> <span class="token punctuation">{</span> locale<span class="token punctuation">,</span> format<span class="token punctuation">,</span> label<span class="token punctuation">,</span> query<span class="token punctuation">,</span> placeholder<span class="token punctuation">,</span> columns<span class="token punctuation">,</span> spellcheck<span class="token punctuation">,</span> autocomplete<span class="token punctuation">,</span> autocapitalize<span class="token punctuation">,</span> filter<span class="token punctuation">,</span> datalist<span class="token punctuation">,</span> disabled<span class="token punctuation">,</span> required<span class="token punctuation">,</span> width <span class="token punctuation">}</span><span class="token operator">?</span><span class="token operator">:</span> <span class="token punctuation">{</span> locale<span class="token operator">:</span> any<span class="token punctuation">;</span> format<span class="token operator">?</span><span class="token operator">:</span> any<span class="token punctuation">;</span> label<span class="token operator">:</span> any<span class="token punctuation">;</span> query<span class="token operator">?</span><span class="token operator">:</span> string<span class="token punctuation">;</span> placeholder<span class="token operator">?</span><span class="token operator">:</span> string<span class="token punctuation">;</span> columns<span class="token operator">?</span><span class="token operator">:</span> any<span class="token punctuation">;</span> spellcheck<span class="token operator">:</span> any<span class="token punctuation">;</span> autocomplete<span class="token operator">:</span> any<span class="token punctuation">;</span> autocapitalize<span class="token operator">:</span> any<span class="token punctuation">;</span> filter<span class="token operator">?</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">query<span class="token operator">:</span> any</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">(</span><span class="token parameter">d<span class="token operator">:</span> any</span><span class="token punctuation">)</span> <span class="token operator">=></span> boolean<span class="token punctuation">;</span> datalist<span class="token operator">:</span> any<span class="token punctuation">;</span> disabled<span class="token operator">:</span> any<span class="token punctuation">;</span> required<span class="token operator">?</span><span class="token operator">:</span> boolean<span class="token punctuation">;</span> width<span class="token operator">:</span> any<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">any</span></code></pre>
    /observablehq/inputs ISC
    0
  • function createDate({
      label,
      min,
      max,
      required,
      readonly,
      disabled,
      width,
      value,
      ...options
    } = {}, {
      type,
      format,
      ...ops
    }) {
      const input = html`<input type=${type} name=date readonly=${readonly} disabled=${disabled} required=${required} min=${format(min)} max=${format(max)}>`;
      
      //...
    }
    
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">function</span> <span class="token function">createDate</span><span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span> label<span class="token punctuation">,</span> min<span class="token punctuation">,</span> max<span class="token punctuation">,</span> required<span class="token punctuation">,</span> readonly<span class="token punctuation">,</span> disabled<span class="token punctuation">,</span> width<span class="token punctuation">,</span> value<span class="token punctuation">,</span> <span class="token operator">...</span>options <span class="token punctuation">}</span><span class="token operator">:</span> <span class="token punctuation">{</span> label<span class="token operator">:</span> any<span class="token punctuation">;</span> min<span class="token operator">:</span> any<span class="token punctuation">;</span> max<span class="token operator">:</span> any<span class="token punctuation">;</span> required<span class="token operator">:</span> any<span class="token punctuation">;</span> readonly<span class="token operator">:</span> any<span class="token punctuation">;</span> disabled<span class="token operator">:</span> any<span class="token punctuation">;</span> width<span class="token operator">:</span> any<span class="token punctuation">;</span> value<span class="token operator">:</span> any<span class="token punctuation">;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> type<span class="token punctuation">,</span> format<span class="token punctuation">,</span> <span class="token operator">...</span>ops <span class="token punctuation">}</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token punctuation">[</span>x<span class="token operator">:</span> string<span class="token punctuation">]</span><span class="token operator">:</span> any<span class="token punctuation">;</span> type<span class="token operator">:</span> any<span class="token punctuation">;</span> format<span class="token operator">:</span> any<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">any</span></code></pre>
    /observablehq/inputs ISC
    0
  • function color({
      label,
      value,
      required,
      datalist,
      readonly,
      disabled,
      width,
      ...options
    } = {}) {
      
      //...
    const input = html`<input
        type=color
        name=text
        value=${value}
        id=${id}
        list=${listId}
        readonly=${readonly}
        disabled=${disabled}
        required=${required}
      >`;
      
      //...
    }
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">function</span> <span class="token function">color</span><span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span> label<span class="token punctuation">,</span> value<span class="token punctuation">,</span> required<span class="token punctuation">,</span> datalist<span class="token punctuation">,</span> readonly<span class="token punctuation">,</span> disabled<span class="token punctuation">,</span> width<span class="token punctuation">,</span> <span class="token operator">...</span>options <span class="token punctuation">}</span><span class="token operator">?</span><span class="token operator">:</span> <span class="token punctuation">{</span> label<span class="token operator">:</span> any<span class="token punctuation">;</span> value<span class="token operator">:</span> any<span class="token punctuation">;</span> required<span class="token operator">:</span> any<span class="token punctuation">;</span> datalist<span class="token operator">:</span> any<span class="token punctuation">;</span> readonly<span class="token operator">:</span> any<span class="token punctuation">;</span> disabled<span class="token operator">:</span> any<span class="token punctuation">;</span> width<span class="token operator">:</span> any<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">any</span></code></pre>
    /observablehq/inputs ISC
    0
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples