Please enable JavaScript to use RhodeCode Enterprise
Commit Description:
merge
Commit Description:
merge
/**
* This decorator caches the results of a getter or method such that
* the results are lazily computed once, and then cached.
* @private
*/
export function cache ( target , key , descriptor ) {
if ( descriptor . get ) {
let get = descriptor . get ;
descriptor . get = function () {
let value = get . call ( this );
Object . defineProperty ( this , key , { value });
return value ;
};
} else if ( typeof descriptor . value === 'function' ) {
let fn = descriptor . value ;
return {
get () {
let cache = new Map ;
function memoized (... args ) {
let key = args . length > 0 ? args [ 0 ] : 'value' ;
if ( cache . has ( key )) {
return cache . get ( key );
}
let result = fn . apply ( this , args );
cache . set ( key , result );
return result ;
};
Object . defineProperty ( this , key , { value : memoized });
return memoized ;
}
};
}
}
Site-wide shortcuts
/
Use quick search box
g h
Goto home page
g g
Goto my private gists page
g G
Goto my public gists page
n r
New repository page
n g
New gist page
Repositories
g s
Goto summary page
g c
Goto changelog page
g f
Goto files page
g F
Goto files page with file search activated
g p
Goto pull requests page
g o
Goto repository settings
g O
Goto repository permissions settings