-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First prototype of public engine api. Pending more work to complete t…
…he first bundle version for the browser.
- Loading branch information
1 parent
a52b618
commit cdc832f
Showing
48 changed files
with
148 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
.idea | ||
.DS_Store | ||
/coverage | ||
/npm-debug.log | ||
/.idea | ||
*~ | ||
/node_modules | ||
*.swp | ||
|
||
# transpiled code directories | ||
/src | ||
/test/src | ||
/test/src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# SPLIT Cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
"name": "split-cache", | ||
"version": "0.0.1", | ||
"description": "Split Engine", | ||
"readme": "README.md", | ||
"author": "Facundo Cabrera <[email protected]>", | ||
"homepage": "https://github.com/splitio/javascript-client", | ||
"license": "Apache-2.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.idea | ||
.DS_Store | ||
/coverage | ||
/npm-debug.log | ||
/.idea | ||
*~ | ||
/node_modules | ||
*.swp | ||
|
||
# transpiled code directories | ||
/src | ||
/test/src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# SPLIT Engine | ||
|
||
This package is responsible of parse the AST of SPLIT DSL in order to be able | ||
to evaluate if a given key is enabled given a feature to be evaluated. | ||
|
||
If you are looking for how we manage data storage (AST storage basically), you | ||
should be looking into the package `split-cache`. |
4 changes: 2 additions & 2 deletions
4
packages/split-parser/es6/combiners/and.js → packages/split-engine/es6/combiners/and.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
{ | ||
"name": "split-parser", | ||
"name": "split-engine", | ||
"version": "0.0.1", | ||
"description": "Split AST parser", | ||
"description": "Split Engine", | ||
"readme": "README.md", | ||
"author": "Facundo Cabrera <[email protected]>", | ||
"homepage": "https://github.com/splitio/javascript-client", | ||
"license": "Apache-2.0", | ||
"repository": "https://github.com/splitio/javascript-client/tree/master/packages/split-parser", | ||
"repository": "https://github.com/splitio/javascript-client/tree/master/packages/split-engine", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"build": "babel es6 --out-dir src --source-maps", | ||
|
@@ -19,12 +20,12 @@ | |
"babel-plugin-syntax-object-rest-spread": "^6.3.13", | ||
"babel-plugin-transform-object-rest-spread": "^6.3.13", | ||
"babel-preset-es2015": "^6.3.13", | ||
"tape": "^4.2.2", | ||
"murmurhash-js": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^1.10.3", | ||
"jscs": "^2.7.0" | ||
"jscs": "^2.7.0", | ||
"tape": "^4.2.2" | ||
}, | ||
"babel": { | ||
"presets": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
|
||
var tape = require('tape'); | ||
var andCombinerFactory = require('split-engine/src/combiners/and'); | ||
|
||
tape('', (assert) => { | ||
let inputKey = 'sample'; | ||
let inputSeed = 1234; | ||
let evaluationResult = true; | ||
|
||
function evaluator(key, seed) { | ||
assert.true(key === inputKey, 'key should be equals'); | ||
assert.true(seed === inputSeed, 'seed should be equals'); | ||
|
||
return evaluationResult; | ||
} | ||
|
||
let predicates = [evaluator]; | ||
|
||
let andCombinerEvaluator = andCombinerFactory(predicates); | ||
|
||
assert.true( | ||
andCombinerEvaluator(inputKey, inputSeed) === evaluationResult, | ||
`evaluator should return ${evaluationResult}` | ||
); | ||
assert.end(); | ||
}); |
4 changes: 2 additions & 2 deletions
4
...ges/split-parser/test/es6/engine/index.js → ...ges/split-engine/test/es6/engine/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...ges/split-parser/test/es6/matchers/all.js → ...ges/split-engine/test/es6/matchers/all.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...lit-parser/test/es6/matchers/whitelist.js → ...lit-engine/test/es6/matchers/whitelist.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...split-parser/test/es6/parser/condition.js → ...split-engine/test/es6/parser/condition.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...-parser/test/es6/transforms/partitions.js → ...-engine/test/es6/transforms/partitions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...t-parser/test/es6/transforms/whitelist.js → ...t-engine/test/es6/transforms/whitelist.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
.idea | ||
.DS_Store | ||
/coverage | ||
/npm-debug.log | ||
/.idea | ||
*~ | ||
/node_modules | ||
*.swp | ||
/src | ||
/test/src | ||
/test/src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# SPLIT SDK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
var writer = require('split-cache').writer; | ||
|
||
var core = { | ||
schedule(fn /*: function */, delay /*: number */, ...params /*:? Array<any> */) { | ||
setTimeout(fn, delay, ...params); | ||
}, | ||
|
||
start(authorizationKey /*: string */) { | ||
return writer(authorizationKey).then(storage => { | ||
if (process.env.NODE_ENV === 'development') { | ||
storage.print(); | ||
} | ||
|
||
// fire cache updater each 5 seconds | ||
this.schedule(writer, 5000, authorizationKey); | ||
|
||
return storage; | ||
}); | ||
} | ||
}; | ||
|
||
module.exports = core; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./browser'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"main": "node.js", | ||
"browser": "browser.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
var core = require('./core'); | ||
|
||
function splitter(authorizationKey /*: string */) { | ||
return core.start(authorizationKey).then(storage => { | ||
return { | ||
/** | ||
* Evaluates is a given userId is enabled for a given feature. | ||
*/ | ||
isOn(userId /*: string */, featureName /*: string */) { | ||
return storage.getSplit(featureName).evaluate(userId); | ||
} | ||
}; | ||
}); | ||
} | ||
|
||
module.exports = splitter; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
"name": "split", | ||
"version": "0.0.1", | ||
"description": "Split Engine", | ||
"readme": "README.md", | ||
"author": "Facundo Cabrera <[email protected]>", | ||
"homepage": "https://github.com/splitio/javascript-client", | ||
"license": "Apache-2.0", | ||
|
@@ -23,9 +24,14 @@ | |
"tape": "^4.2.2" | ||
}, | ||
"devDependencies": { | ||
"browserify": "^13.0.0", | ||
"eslint": "^1.10.3", | ||
"jscs": "^2.7.0" | ||
}, | ||
"engines": { | ||
"node": ">=0.12", | ||
"npm" : "^3" | ||
}, | ||
"babel": { | ||
"presets": [ | ||
"es2015" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
npm link packages/split | ||
npm link packages/split-engine | ||
npm link packages/split-cache | ||
npm link packages/split-parser | ||
npm link packages/split | ||
|
||
cd packages/split-cache | ||
rm -rf src/ | ||
npm install | ||
npm run watch & | ||
npm run watch-test & | ||
cd - | ||
|
||
cd packages/split-parser | ||
cd packages/split-engine | ||
rm -rf src/ | ||
npm install | ||
npm run watch & | ||
npm run watch-test & | ||
cd - |