mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-12 10:52:47 +00:00
updated bunch of file paths and changed the way posts are loaded
This commit is contained in:
39
node_modules/memoizee/ext/ref-counter.js
generated
vendored
Normal file
39
node_modules/memoizee/ext/ref-counter.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
// Reference counter, useful for garbage collector like functionality
|
||||
|
||||
'use strict';
|
||||
|
||||
var d = require('d')
|
||||
, extensions = require('../lib/registered-extensions')
|
||||
|
||||
, create = Object.create, defineProperties = Object.defineProperties;
|
||||
|
||||
extensions.refCounter = function (ignore, conf, options) {
|
||||
var cache, postfix;
|
||||
|
||||
cache = create(null);
|
||||
postfix = (options.async && extensions.async) ? 'async' : '';
|
||||
|
||||
conf.on('set' + postfix, function (id, length) { cache[id] = length || 1; });
|
||||
conf.on('get' + postfix, function (id) { ++cache[id]; });
|
||||
conf.on('delete' + postfix, function (id) { delete cache[id]; });
|
||||
conf.on('clear' + postfix, function () { cache = {}; });
|
||||
|
||||
defineProperties(conf.memoized, {
|
||||
deleteRef: d(function () {
|
||||
var id = conf.get(arguments);
|
||||
if (id === null) return null;
|
||||
if (!cache[id]) return null;
|
||||
if (!--cache[id]) {
|
||||
conf.delete(id);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}),
|
||||
getRefCount: d(function () {
|
||||
var id = conf.get(arguments);
|
||||
if (id === null) return 0;
|
||||
if (!cache[id]) return 0;
|
||||
return cache[id];
|
||||
})
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user