mirror of
				https://github.com/flynx/pWiki.git
				synced 2025-10-31 02:50:08 +00:00 
			
		
		
		
	more experiments...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									882bfb27d8
								
							
						
					
					
						commit
						843e06bebc
					
				
							
								
								
									
										46
									
								
								pwiki2.js
									
									
									
									
									
								
							
							
						
						
									
										46
									
								
								pwiki2.js
									
									
									
									
									
								
							| @ -413,6 +413,18 @@ module.store = | |||||||
| // 			- a router?
 | // 			- a router?
 | ||||||
| // 			- substores?
 | // 			- substores?
 | ||||||
| 
 | 
 | ||||||
|  | // XXX use super...
 | ||||||
|  | var metaProxy =  | ||||||
|  | function(meth){ | ||||||
|  | 	return function(path, ...args){ | ||||||
|  | 		var store = this.substore(path) | ||||||
|  | 		return store != null ? | ||||||
|  | 			//BaseStore[meth].call(this, path, ...args)
 | ||||||
|  | 			object.parentCall(MetaStore, meth, this, path, ...args) | ||||||
|  | 			: this.data[store][meth](path.slice(store.length), ...args) } } | ||||||
|  | 
 | ||||||
|  | // XXX STORETEST for this to work need a way to test if something is a store -- i.e.
 | ||||||
|  | // 		either make things Constructor's or some other test...
 | ||||||
| // XXX should this be a mixin???
 | // XXX should this be a mixin???
 | ||||||
| // XXX TEST...
 | // XXX TEST...
 | ||||||
| var MetaStore = | var MetaStore = | ||||||
| @ -422,17 +434,18 @@ module.MetaStore = { | |||||||
| 	//data: undefined,
 | 	//data: undefined,
 | ||||||
| 	data: {}, | 	data: {}, | ||||||
| 
 | 
 | ||||||
|  | 	// XXX STORETEST revise store test....
 | ||||||
| 	__substores: undefined, | 	__substores: undefined, | ||||||
| 	get substores(){ | 	get substores(){ | ||||||
| 		return this.__substores  | 		return this.__substores  | ||||||
| 			?? (this.__substores = Object.entries(this.data) | 			?? (this.__substores = Object.entries(this.data) | ||||||
| 				.filter(function([path, value]){ | 				.filter(function([path, value]){ | ||||||
| 					return value instanceof BaseStore }) | 					return object.childOf(value, BaseStore) }) | ||||||
| 				.map(function([path, _]){ | 				.map(function([path, _]){ | ||||||
| 					return path })) }, | 					return path })) }, | ||||||
| 	substore: function(path){ | 	substore: function(path){ | ||||||
| 		path = module.path.normalize(path, 'string') | 		path = module.path.normalize(path, 'string') | ||||||
| 		var stpre = this.substores | 		var store = this.substores | ||||||
| 			.filter(function(p){ | 			.filter(function(p){ | ||||||
| 				return path.startsWith(p) }) | 				return path.startsWith(p) }) | ||||||
| 			.sort(function(a, b){ | 			.sort(function(a, b){ | ||||||
| @ -443,35 +456,22 @@ module.MetaStore = { | |||||||
| 			undefined | 			undefined | ||||||
| 			: store }, | 			: store }, | ||||||
| 	 | 	 | ||||||
|  | 	// XXX STORETEST revise store test....
 | ||||||
| 	__paths__: function(){ | 	__paths__: function(){ | ||||||
| 		var that = this | 		var that = this | ||||||
| 		var data = this.data | 		var data = this.data | ||||||
| 		Object.keys(data) | 		Object.keys(data) | ||||||
| 			.map(function(path){ | 			.map(function(path){ | ||||||
| 				return data[path] instanceof BaseStore ? | 				return object.childOf(data[path], BaseStore) ? | ||||||
| 					data[path].paths() | 					data[path].paths() | ||||||
| 					: data[path] }) | 					: data[path] }) | ||||||
| 			.flat() }, | 			.flat() }, | ||||||
| 	__exists__: function(path){ | 
 | ||||||
| 		var store = this.substore(path) | 	__exists__: metaProxy('__exists__'), | ||||||
| 		return store == null ? | 	__get__: metaProxy('__get__'), | ||||||
| 			(path in this.data  | 	__delete__: metaProxy('__delete__'), | ||||||
| 				?? path) | 	// XXX need to write a store as-is...
 | ||||||
| 			: this.data[store].exists(path.slice(store.length)) }, | 	__update__: metaProxy('__update__'), | ||||||
| 	__get__: function(path){ |  | ||||||
| 		var store = this.substore(path) |  | ||||||
| 		return store == null ? |  | ||||||
| 			BaseStore.__get__.call(this, path) |  | ||||||
| 			: this.__get__(store).get(path.slice(store.length)) }, |  | ||||||
| 	__update__: function(path, data={}, mode){ |  | ||||||
| 		var store = this.substore(path) |  | ||||||
| 		store == null ? |  | ||||||
| 			BaseStore.__update__.call(this, path, data, mode) |  | ||||||
| 			: this.data[store].update(path.slice(store.length), data, mode) }, |  | ||||||
| 	__delete__: function(path){ |  | ||||||
| 		var store = this.substore(path) |  | ||||||
| 		// XXX
 |  | ||||||
| 	}, |  | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user