mirror of
				https://github.com/flynx/pWiki.git
				synced 2025-10-31 19:10:08 +00:00 
			
		
		
		
	notes asnd docs...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									276e90e805
								
							
						
					
					
						commit
						3e2be6b7e9
					
				| @ -28,12 +28,58 @@ var pwpath = require('../path') | |||||||
| //
 | //
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // XXX need support for:
 | //
 | ||||||
| // 		'update', <path>, <value>
 | //	makeIndexed(<name>, <generate>[, <options>])
 | ||||||
| // 		'remove', <path>
 | //		-> <index-handler> 
 | ||||||
|  | //
 | ||||||
|  | //	Get merged data (cached)
 | ||||||
|  | //	<index-handler>()
 | ||||||
|  | //	<index-handler>('get')
 | ||||||
|  | //		-> <data>
 | ||||||
|  | //
 | ||||||
|  | //	Get local data (uncached)...
 | ||||||
|  | //	<index-handler>('local')
 | ||||||
|  | //		-> <data>
 | ||||||
|  | //
 | ||||||
|  | //	Clear cache...
 | ||||||
|  | //	<index-handler>('clear')
 | ||||||
|  | //		-> <data>
 | ||||||
|  | //
 | ||||||
|  | //	Reset cache (clear then get)...
 | ||||||
|  | //	<index-handler>('reset')
 | ||||||
|  | //		-> <data>
 | ||||||
|  | //
 | ||||||
|  | //	Run custom action...
 | ||||||
|  | //	<index-handler>(<action-name>), ...)
 | ||||||
|  | //		-> <data>
 | ||||||
|  | //
 | ||||||
|  | //
 | ||||||
|  | //
 | ||||||
|  | // Special methods:
 | ||||||
|  | //
 | ||||||
|  | // 	Special method to generate local <data>...
 | ||||||
|  | // 	.__<name>__()
 | ||||||
|  | // 		-> <data>
 | ||||||
|  | //
 | ||||||
|  | // 	Merge local data with other sources...
 | ||||||
|  | // 	.__<name>_merge__(<data>)
 | ||||||
|  | // 		-> <data>
 | ||||||
|  | //
 | ||||||
|  | // 	Handle custom action...
 | ||||||
|  | // 	.__<name>_<action-name>__(<data>. ...)
 | ||||||
|  | // 		-> <data>
 | ||||||
|  | //
 | ||||||
|  | //
 | ||||||
|  | //
 | ||||||
|  | // Special attributes:
 | ||||||
|  | //
 | ||||||
|  | // 	Cached data...
 | ||||||
|  | // 	.__<name>_cache / .<name>
 | ||||||
|  | //
 | ||||||
| //
 | //
 | ||||||
| var makeIndexed =  | var makeIndexed =  | ||||||
| function(name, generate, options={}){ | function(name, generate, options={}){ | ||||||
|  | 	// XXX revise default...
 | ||||||
| 	var cache = !!options.attr ? | 	var cache = !!options.attr ? | ||||||
| 		name | 		name | ||||||
| 		: `__${name}_cache` | 		: `__${name}_cache` | ||||||
| @ -72,11 +118,12 @@ function(name, generate, options={}){ | |||||||
| 					this[cache] | 					this[cache] | ||||||
| 					: meth.call(this, 'reset') | 					: meth.call(this, 'reset') | ||||||
| 				return _await(this, this[cache] =  | 				return _await(this, this[cache] =  | ||||||
| 					(action in options  | 					// NOTE: this[action_meth] will fully shadow options[action]...
 | ||||||
|  | 					action_meth in this ? | ||||||
|  | 						this[action_meth](cur, ...args) | ||||||
|  | 					: (action in options  | ||||||
| 							&& typeof(options[action]) == 'function') ? | 							&& typeof(options[action]) == 'function') ? | ||||||
| 						options[action].call(this, cur, ...args) | 						options[action].call(this, cur, ...args) | ||||||
| 					: action_meth in this ? |  | ||||||
| 						this[action_meth](cur, ...args) |  | ||||||
| 					: cur) } | 					: cur) } | ||||||
| 			// get...
 | 			// get...
 | ||||||
| 			return _await(this, | 			return _await(this, | ||||||
| @ -103,6 +150,7 @@ function(name, generate, options={}){ | |||||||
| var indexTest =  | var indexTest =  | ||||||
| module.indexTest = | module.indexTest = | ||||||
| { | { | ||||||
|  | 	// XXX rename???
 | ||||||
| 	get indexi(){ | 	get indexi(){ | ||||||
| 		var that = this | 		var that = this | ||||||
| 		return object.deepKeys(this) | 		return object.deepKeys(this) | ||||||
| @ -126,7 +174,7 @@ module.indexTest = | |||||||
| 	//
 | 	//
 | ||||||
| 	moo: makeIndexed('moo', () => 123), | 	moo: makeIndexed('moo', () => 123), | ||||||
| 
 | 
 | ||||||
| 	_foo_index: makeIndexed('foo', () => 123, { | 	foo_index: makeIndexed('foo', () => 123, { | ||||||
| 		attr: true, | 		attr: true, | ||||||
| 		add: function(cur, val){ | 		add: function(cur, val){ | ||||||
| 			return cur + val }, | 			return cur + val }, | ||||||
| @ -136,9 +184,16 @@ module.indexTest = | |||||||
| 		return cur + val }, | 		return cur + val }, | ||||||
| 	boo: makeIndexed('boo', () => 123), | 	boo: makeIndexed('boo', () => 123), | ||||||
| 
 | 
 | ||||||
| 	__amoo_add__: async function(cur, val){ | 	__soo_add__: async function(cur, val){ | ||||||
| 		return await cur + val }, | 		return await cur + val }, | ||||||
| 	amoo: makeIndexed('amoo', async () => 123), | 	__soo: makeIndexed('soo', async () => 123), | ||||||
|  | 	get soo(){ | ||||||
|  | 		return this.__soo() } | ||||||
|  | 
 | ||||||
|  | 	// XXX need a way to link indexes...
 | ||||||
|  | 	// 		Ex:
 | ||||||
|  | 	// 			sum -> soo + boo + foo + moo
 | ||||||
|  | 	// 			...changing any of the summed values should drop cache of sum
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user