This repository has been archived by the owner on Feb 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Add caching mech to bem-walk #44
Labels
Comments
Related #39 |
Open
APII think API should look like this: const config = require('bem-config')();
const walk = require('bem-walk');
const levelMap = config.levelMapSync();
const storage = new walk.Storage();
walk(['path/to/level'], {
levels: levelMap,
storage: storage
}); The const walk = require('bem-walk');
const storage = new walk.Storage();
storage.set('path/to/level', {
'block': [
{
entity: 'block',
tech: 'css',
level: 'path/to/level',
path: 'path/to/level/block/block.css'
},
{
entity: 'block',
tech: 'js',
level: 'path/to/level',
path: 'path/to/level/block/block.js'
},
/* ... */
]
});
const introspection = storage.get('path/to/level');
storage.has('path/to/level'); // true Example: Imagine that you need scan The first require In addition need scan const config = require('bem-config')();
const walk = require('bem-walk');
const levelMap = config.levelMapSync();
const storage = new walk.Storage();
// Scan first bundle:
// the `lib/common.blocks`, `common.blocks` and `desktop.blocks` will be get from file system.
walk(['lib/common.blocks', 'common.blocks', 'desktop.blocks'], {
levels: levelMap,
storage: storage
});
// Scan second bundle:
// the `'lib/common.blocks` and `common.blocks` will be get from storage,
// the `touch.blocks` will be get from file system.
walk(['lib/common.blocks', 'common.blocks', 'touch.blocks'], {
levels: config.levelMapSync(),
storage: storage
});
// save `introspection` to file system
const introspection = storage.get('lib/common.blocks');
saveIntrospection(introspection); After we can load const config = require('bem-config')();
const walk = require('bem-walk');
const levelMap = config.levelMapSync();
const storage = new walk.Storage();
// load `introspection` from file system
const introspection = loadIntrospection('lib/common.blocks');
storage.set('lib/common.blocks', introspection);
// Scan first bundle:
// the `lib/common.blocks` will be get from storage
// the `common.blocks` and `desktop.blocks` will be get from file system.
walk(['lib/common.blocks', 'common.blocks', 'desktop.blocks'], {
levels: levelMap,
storage: storage
});
// Scan second bundle:
// the `'lib/common.blocks` and `common.blocks` will be get from storage,
// the `touch.blocks` will be get from file system.
walk(['lib/common.blocks', 'common.blocks', 'touch.blocks'], {
levels: config.levelMapSync(),
storage: storage
}); ImplementationWe can add if (storage.has('path/to/level')) {
storageWalker(level, add);
callback();
} else {
walk({ path: level, naming: naming }, add, callback);
} |
Closed
Related #14 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Some kind of storage class with simple interface (get/set/clean/clone/merge?).
The text was updated successfully, but these errors were encountered: