How to use mem - 10 common examples

To help you get started, we’ve selected a few mem 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 artyomtrityak / just-test-it / static / screens / books / main.js View on Github external
onBeforeRoute: function() {
      // Init main module container
      this.container = Mem.set('container', View, {
        container: $('#wrap')
      });

      // Init menu
      this.menuModule = Mem.set('menu', MenuModule);
      this.menuModule.showMenu(this.container.getMenuContainer(), 'books');

      // Init books
      this.booksModule = Mem.set('books', BooksModule);
      this.booksModule.showList(this.container.getBooksContainer());

      //Init comments
      this.commentsModule = Mem.set('comments', CommentsModule);
    },
github artyomtrityak / just-test-it / static / screens / books / main.js View on Github external
onBeforeRoute: function() {
      // Init main module container
      this.container = Mem.set('container', View, {
        container: $('#wrap')
      });

      // Init menu
      this.menuModule = Mem.set('menu', MenuModule);
      this.menuModule.showMenu(this.container.getMenuContainer(), 'books');

      // Init books
      this.booksModule = Mem.set('books', BooksModule);
      this.booksModule.showList(this.container.getBooksContainer());

      //Init comments
      this.commentsModule = Mem.set('comments', CommentsModule);
    },
github artyomtrityak / just-test-it / static / screens / books / main.js View on Github external
onBeforeRoute: function() {
      // Init main module container
      this.container = Mem.set('container', View, {
        container: $('#wrap')
      });

      // Init menu
      this.menuModule = Mem.set('menu', MenuModule);
      this.menuModule.showMenu(this.container.getMenuContainer(), 'books');

      // Init books
      this.booksModule = Mem.set('books', BooksModule);
      this.booksModule.showList(this.container.getBooksContainer());

      //Init comments
      this.commentsModule = Mem.set('comments', CommentsModule);
    },
github artyomtrityak / just-test-it / static / screens / authors / main.js View on Github external
onBeforeRoute: function() {
      // Init main module container
      this.container = Mem.set('container', View, {
        container: $('#wrap')
      });

      this.menuModule = Mem.set('menu', MenuModule);
      this.menuModule.showMenu(this.container.getMenuContainer(), 'authors');
    },
github artyomtrityak / just-test-it / static / screens / authors / main.js View on Github external
onBeforeRoute: function() {
      // Init main module container
      this.container = Mem.set('container', View, {
        container: $('#wrap')
      });

      this.menuModule = Mem.set('menu', MenuModule);
      this.menuModule.showMenu(this.container.getMenuContainer(), 'authors');
    },
github artyomtrityak / just-test-it / static / screens / books / main.js View on Github external
onBeforeRoute: function() {
      // Init main module container
      this.container = Mem.set('container', View, {
        container: $('#wrap')
      });

      // Init menu
      this.menuModule = Mem.set('menu', MenuModule);
      this.menuModule.showMenu(this.container.getMenuContainer(), 'books');

      // Init books
      this.booksModule = Mem.set('books', BooksModule);
      this.booksModule.showList(this.container.getBooksContainer());

      //Init comments
      this.commentsModule = Mem.set('comments', CommentsModule);
    },
github RocketChat / Rocket.Chat / app / emoji-emojione / lib / rocketchat.js View on Github external
const category = fname.indexOf('-1f3f') >= 0 ? 'diversity' : ns.emojioneList[shortname].category;
		const title = ns.imageTitleTag ? `title="${ shortname }"` : '';
		// const size = ns.spriteSize === '32' || ns.spriteSize === '64' ? ns.spriteSize : '32';
		// if the emoji path has been set, we'll use the provided path, otherwise we'll use the default path
		const ePath = ns.defaultPathPNG !== ns.imagePathPNG ? ns.imagePathPNG : `${ ns.defaultPathPNG + ns.emojiSize }/`;

		// depending on the settings, we'll either add the native unicode as the alt tag, otherwise the shortname
		const alt = ns.unicodeAlt ? ns.convert(unicode.toUpperCase()) : shortname;

		if (ns.sprites) {
			return `<span title="" class="emojione emojione-${ category } _${ fname }">${ alt }</span>`;
		}
		return `<img src="${ ePath }${ fname }${ ns.fileExtension }" title="" alt="${ alt }" class="emojione">`;
	});

	const convertUnicode = mem(function(entire, m1, m2, m3) {
		const mappedUnicode = ns.mapUnicodeToShort();

		if ((typeof m3 === 'undefined') || (m3 === '') || !(ns.unescapeHTML(m3) in ns.asciiList)) {
			// if the ascii doesnt exist just return the entire match
			return entire;
		}

		m3 = ns.unescapeHTML(m3);
		const unicode = ns.asciiList[m3];
		const shortname = mappedUnicode[unicode];
		const category = unicode.indexOf('-1f3f') &gt;= 0 ? 'diversity' : ns.emojioneList[shortname].category;
		const title = ns.imageTitleTag ? `title="${ ns.escapeHTML(m3) }"` : '';
		// const size = ns.spriteSize === '32' || ns.spriteSize === '64' ? ns.spriteSize : '32';
		// if the emoji path has been set, we'll use the provided path, otherwise we'll use the default path
		const ePath = ns.defaultPathPNG !== ns.imagePathPNG ? ns.imagePathPNG : `${ ns.defaultPathPNG + ns.emojiSize }/`;
github xodio / hm-def / src / signature.js View on Github external
S.unchecked.map (types => S.reduce
      (f => x => $.Function ([x, f]))
      (types[types.length - 1])
      (types.slice (0, -1))),
  ]));

  //    convertRecordField :: SignatureEntry
  //                          -> Reader (TypeMap (Pair String Type))
  const convertRecordField = memoize (entry => S.pipe ([
    firstChild,
    convertType,
    S.unchecked.map (valueType => [entry.text, valueType]),
  ]) (entry));

  //    convertRecord :: SignatureEntry -> Reader (TypeMap Type)
  const convertRecord = memoize (S.pipe ([
    children,
    S.map (convertRecordField),
    S.unchecked.sequence (Reader),
    S.unchecked.map (fromPairs),
    S.unchecked.map ($.RecordType),
  ]));

  //    convertTypevar :: SignatureEntry -> Type
  const convertTypevar = memoize (x => $.TypeVariable (text (x)));

  //    unaryTypevar :: SignatureEntry -> (Type -> Type)
  const unaryTypevar = memoize (x => $.UnaryTypeVariable (text (x)));

  //    convertConstrainedType :: SignatureEntry -> Reader (TypeMap Type)
  const convertConstrainedType = memoize (entry => S.pipe ([
    firstChild,
github desktop / desktop / app / src / lib / stores / pull-request-store.ts View on Github external
let mostRecentlyUpdated = pullRequestsFromAPI[0].updated_at

    const prsToDelete = new Array()
    const prsToUpsert = new Array()

    // The API endpoint for this PR, i.e api.github.com or a GHE url
    const { endpoint } = repository
    const store = this.repositoryStore

    // Upsert will always query the database for a repository. Given that
    // we've receive these repositories in a batch response from the API
    // it's pretty unlikely that they'd differ between PRs so we're going
    // to use the upsert just to ensure that the repo exists in the database
    // and reuse the same object without going to the database for all that
    // follow.
    const upsertRepo = mem(store.upsertGitHubRepository.bind(store), {
      // The first argument which we're ignoring here is the endpoint
      // which is constant throughout the lifetime of this function.
      // The second argument is an `IAPIRepository` which is basically
      // the raw object that we got from the API which could consist of
      // more than just the fields we've modelled in the interface. The
      // only thing we really care about to determine whether the
      // repository has already been inserted in the database is the clone
      // url since that's what the upsert method uses as its key.
      cacheKey: (_, repo) =&gt; repo.clone_url,
    })

    for (const pr of pullRequestsFromAPI) {
      // We can do this string comparison here rather than convert to date
      // because ISO8601 is lexicographically sortable
      if (pr.updated_at &gt; mostRecentlyUpdated) {
        mostRecentlyUpdated = pr.updated_at
github jjug-ccc / cfp / src / main / resources / templates / index.html View on Github external
axios.get('/metrics').then(function (res) {
                    var metrics = res.data,
                        mem = metrics['mem'],
                        memFree = metrics['mem.free'],
                        heap = metrics['heap'],
                        heapUsed = metrics['heap.used'],
                        heapCommited = metrics['heap.committed'],
                        activeSession = metrics['httpsessions.active'];
                    // Memory
                    data.setValue(0, 1, 100 * memFree / mem);
                    // Heap (Used)
                    data.setValue(1, 1, 100 * heapUsed / heap);
                    // Heap (Commited)
                    data.setValue(2, 1, 100 * heapCommited / heap);
                    chart.draw(data, options);
                    // Active Session
                    document.getElementById('activeSession').innerText = activeSession;
                });
            }

mem

Memoize functions - An optimization used to speed up consecutive function calls by caching the result of calls with identical input

MIT
Latest version published 1 year ago

Package Health Score

61 / 100
Full package analysis