Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var gulp = require('gulp');
var fs = require('fs');
var path = require('path');
var _ = require('lodash');
var moment = require('moment');
var EOL = require('os').EOL;
var falcorModel = require('falcor').Model;
var $ref = falcorModel.ref;
var $atom = falcorModel.atom;
// Some constants
var OUTPUT_FILE_NAME = 'sample-data-cache.js';
var OUTPUT_FOLDER = './src/js/stores';
// Sample data JSON
var videos = require('../data/videos.json');
var users = require('../data/users.json');
var comments = require('../data/comments.json');
// Helper function for generating an int from part of a UUID
function getIntFromPartOfUuid(uuid, startIdx, numChars, maxValue) {
var hex = uuid.substr(startIdx, numChars);
return parseInt('0x' + hex) % maxValue;
}
var jsongMerge = require('./../../../src/cache/jsongMerge');
var Model = require('falcor').Model;
var $ref = Model.ref;
var $atom = Model.atom;
var expect = require('chai').expect;
var _ = require('lodash');
/**
* normally i don't test internals but i think the merges
* warrent internal testing. The reason being is that the
* merges are core to the product. If i don't, i will have to
* figure out where bugs are without much clarity into where they
* are.
*/
describe('JSONG - Merge', function() {
it('should write a simple path to the cache.', function() {
var jsong = {
var optimizePathSets = require('./../../../src/cache/optimizePathSets');
var Model = require('falcor').Model;
var $ref = Model.ref;
var $atom = Model.atom;
var expect = require('chai').expect;
var errors = require('./../../../src/exceptions');
/**
* normally i don't test internals but i think the merges
* warrent internal testing. The reason being is that the
* merges are core to the product. If i don't, i will have to
* figure out where bugs are without much clarity into where they
* are.
*/
describe('optimizePathSets', function() {
it('should optimize simple path.', function() {
var cache = getCache();
var paths = [['videosList', 3, 'summary']];
var jsongMerge = require('./../../../src/cache/jsongMerge');
var Model = require('falcor').Model;
var $ref = Model.ref;
var $atom = Model.atom;
var expect = require('chai').expect;
var _ = require('lodash');
/**
* normally i don't test internals but i think the merges
* warrent internal testing. The reason being is that the
* merges are core to the product. If i don't, i will have to
* figure out where bugs are without much clarity into where they
* are.
*/
describe('JSONG - Merge', function() {
it('should write a simple path to the cache.', function() {
var jsong = {
"use strict";
var Model = require("falcor").Model,
$ref = Model.ref,
$atom = Model.atom,
http = require("../../lib/http"),
auth = require("./lib/auth");
module.exports = [ {
route : "account.dyes.length",
get : auth(function(key, pathset) {
return http.json("https://api.guildwars2.com/v2/account/dyes?access_token=" + key).then(function(resp) {
return {
path : pathset,
value : $atom(resp.length)
};
});
})
}, {
"use strict";
var Model = require("falcor").Model,
$ref = Model.ref,
$atom = Model.atom,
$error = Model.atom,
http = require("../lib/http"),
map = require("./lib/map-ids"),
fields = require("./lib/fields");
module.exports = [ {
route : "colors.length",
get : function(pathset) {
return http.json("https://api.guildwars2.com/v2/colors")
.then(function(json) {
return {
path : pathset,
value : $atom(json.length)
};
"use strict";
var Model = require("falcor").Model,
$error = Model.error,
$atom = Model.atom,
$ref = Model.ref,
chunk = require("./lib/chunk"),
map = require("./lib/map-ids"),
fields = require("./lib/fields");
module.exports = [ {
route : "colorsById[{integers:ids}].id",
get : function(pathset) {
return pathset.ids.map(function(id) {
return {
path : [ pathset[0], id, pathset[2] ],
value : $atom(id)
};
});
},
}, {