mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-30 10:30:08 +00:00
cleanup and minor refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
2d0b965655
commit
2129c967e5
@ -14,21 +14,21 @@ var pwpath = require('../path')
|
|||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
//
|
// XXX move this to a separate module (???)
|
||||||
// - define (name, generate, merge) - DONE
|
// XXX TODO:
|
||||||
// inline - DONE
|
// - define (name, generate, merge) - DONE
|
||||||
// online - DONE
|
// inline - DONE
|
||||||
// - undefine (online) - ???
|
// online - DONE
|
||||||
// - enumerate/list - DONE
|
// - undefine (online) - ???
|
||||||
// - group operations:
|
// - enumerate/list - DONE
|
||||||
// - reset (cache) - DONE
|
// - group operations:
|
||||||
// - custom - DONE
|
// - reset (cache) - DONE
|
||||||
//
|
// - custom - DONE
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// makeIndexed(<name>, <generate>[, <options>])
|
// makeIndex(<name>, <generate>[, <options>])
|
||||||
// -> <index-handler>
|
// -> <index-handler>
|
||||||
//
|
//
|
||||||
// Get merged data (cached)
|
// Get merged data (cached)
|
||||||
@ -100,9 +100,8 @@ var pwpath = require('../path')
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// XXX move this to a separate module (???)
|
var makeIndex =
|
||||||
var makeIndexed =
|
module.makeIndex =
|
||||||
module.makeIndexed =
|
|
||||||
function(name, generate, options={}){
|
function(name, generate, options={}){
|
||||||
// attr names...
|
// attr names...
|
||||||
var cache =
|
var cache =
|
||||||
@ -189,7 +188,6 @@ function(name, generate, options={}){
|
|||||||
options,
|
options,
|
||||||
})) }
|
})) }
|
||||||
|
|
||||||
// XXX make this a mixin...
|
|
||||||
var IndexManagerMixin =
|
var IndexManagerMixin =
|
||||||
module.IndexManagerMixin =
|
module.IndexManagerMixin =
|
||||||
object.Mixin('IndexManagerMixin', {
|
object.Mixin('IndexManagerMixin', {
|
||||||
@ -218,10 +216,14 @@ object.Mixin('IndexManagerMixin', {
|
|||||||
// .index(<action>, ...)
|
// .index(<action>, ...)
|
||||||
// -> <indexi>
|
// -> <indexi>
|
||||||
//
|
//
|
||||||
|
//
|
||||||
|
// .index('new', <name>, <generate>[, <options>])
|
||||||
|
// -> <index-handler>
|
||||||
|
//
|
||||||
index: async function(action='get', ...args){
|
index: async function(action='get', ...args){
|
||||||
// create a new index...
|
// create a new index...
|
||||||
if(action == 'new'){
|
if(action == 'new'){
|
||||||
var res = makeIndexed(...args)
|
var res = makeIndex(...args)
|
||||||
var [name, _, options={}] = args
|
var [name, _, options={}] = args
|
||||||
var attr = name
|
var attr = name
|
||||||
if(options.attr){
|
if(options.attr){
|
||||||
@ -243,15 +245,14 @@ object.Mixin('IndexManagerMixin', {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var indexTest =
|
var indexTest =
|
||||||
module.indexTest =
|
module.indexTest =
|
||||||
IndexManagerMixin({
|
IndexManagerMixin({
|
||||||
// tests...
|
// tests...
|
||||||
//
|
//
|
||||||
moo: makeIndexed('moo', () => 123),
|
moo: makeIndex('moo', () => 123),
|
||||||
|
|
||||||
foo_index: makeIndexed('foo', () => 123, {
|
foo_index: makeIndex('foo', () => 123, {
|
||||||
attr: true,
|
attr: true,
|
||||||
add: function(cur, val){
|
add: function(cur, val){
|
||||||
return cur + val },
|
return cur + val },
|
||||||
@ -259,15 +260,15 @@ IndexManagerMixin({
|
|||||||
|
|
||||||
__boo_add__: function(cur, val){
|
__boo_add__: function(cur, val){
|
||||||
return cur + val },
|
return cur + val },
|
||||||
boo: makeIndexed('boo', () => 123),
|
boo: makeIndex('boo', () => 123),
|
||||||
|
|
||||||
__soo_add__: async function(cur, val){
|
__soo_add__: async function(cur, val){
|
||||||
return await cur + val },
|
return await cur + val },
|
||||||
__soo: makeIndexed('soo', async () => 123),
|
__soo: makeIndex('soo', async () => 123),
|
||||||
get soo(){
|
get soo(){
|
||||||
return this.__soo() },
|
return this.__soo() },
|
||||||
|
|
||||||
__sum: makeIndexed('sum',
|
__sum: makeIndex('sum',
|
||||||
async function(){
|
async function(){
|
||||||
return await this.moo()
|
return await this.moo()
|
||||||
+ await this.foo_index()
|
+ await this.foo_index()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user