mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-18 09:01:40 +00:00
minor fix...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
095da4eb5b
commit
a5b618ab8c
@ -65,6 +65,9 @@ var pwpath = require('../path')
|
|||||||
// -> <data>
|
// -> <data>
|
||||||
// -> <promise>
|
// -> <promise>
|
||||||
//
|
//
|
||||||
|
// NOTE: when a getter is pending (promise), all consecutive calls will
|
||||||
|
// resolve the original getter return value...
|
||||||
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Special methods:
|
// Special methods:
|
||||||
@ -95,6 +98,9 @@ var pwpath = require('../path')
|
|||||||
// Modification time...
|
// Modification time...
|
||||||
// .__<name>_modified
|
// .__<name>_modified
|
||||||
//
|
//
|
||||||
|
// Pending generator promise...
|
||||||
|
// .__<name>_promise
|
||||||
|
//
|
||||||
//
|
//
|
||||||
// Options format:
|
// Options format:
|
||||||
// {
|
// {
|
||||||
@ -143,6 +149,7 @@ function(name, generate, options={}){
|
|||||||
var merge = `__${name}_merge__`
|
var merge = `__${name}_merge__`
|
||||||
var special = `__${name}__`
|
var special = `__${name}__`
|
||||||
var modified = `__${name}_modified`
|
var modified = `__${name}_modified`
|
||||||
|
var promise = `__${name}_promise`
|
||||||
|
|
||||||
// set modified time...
|
// set modified time...
|
||||||
var _stamp = function(that, res){
|
var _stamp = function(that, res){
|
||||||
@ -160,17 +167,19 @@ function(name, generate, options={}){
|
|||||||
var _smake = function(that){
|
var _smake = function(that){
|
||||||
return _stamp(that, _make(that)) }
|
return _stamp(that, _make(that)) }
|
||||||
// unwrap a promised value into cache...
|
// unwrap a promised value into cache...
|
||||||
var promise = `__${name}_promise`
|
|
||||||
var _await = function(obj, val){
|
var _await = function(obj, val){
|
||||||
if(val instanceof Promise){
|
if(val instanceof Promise){
|
||||||
// NOTE: this avoids a race condition when a getter is called
|
// NOTE: this avoids a race condition when a getter is called
|
||||||
// while a previous getter is still pending...
|
// while a previous getter is still pending...
|
||||||
val = obj[promise] =
|
if(obj[promise] == null){
|
||||||
obj[promise]
|
obj[promise] = val
|
||||||
?? val
|
val.then(
|
||||||
val.then(function(value){
|
function(value){
|
||||||
delete obj[promise]
|
delete obj[promise]
|
||||||
obj[cache] = value }) }
|
obj[cache] = value },
|
||||||
|
function(){
|
||||||
|
delete obj[promise] }) }
|
||||||
|
val = obj[promise] }
|
||||||
return val }
|
return val }
|
||||||
|
|
||||||
// build the method...
|
// build the method...
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user