You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I would like to thank you very much for a great library. I do have a small request though, if you could make a small change to it to make array types keep their sorted value in the mockJSON.data. This is done in the getRandomnData() function.
For example, I provided a custom data like:
COMPANY: ["ABC Inc", "DAB Co", "AACC Inc"]
but when I set the random = false flag, it returns random data. To fix that let me show you what I had to do:
function getRandomData(key) {
key = key.substr(1); // remove "@"
//var params = key.match(/\(((\d+),?)+\)/g) || [];
var params = key.match(/\(([^\)]+)\)/g) || [];
if (!(key in $.mockJSON.data)) {
Hello, I would like to thank you very much for a great library. I do have a small request though, if you could make a small change to it to make array types keep their sorted value in the mockJSON.data. This is done in the getRandomnData() function.
For example, I provided a custom data like:
COMPANY: ["ABC Inc", "DAB Co", "AACC Inc"]
but when I set the random = false flag, it returns random data. To fix that let me show you what I had to do:
function getRandomData(key) {
key = key.substr(1); // remove "@"
// console.log(key);
// console.log(params);
return key;
}
// var index = Math.floor(a.length * rand());
return a[$.mockJSON.workingKeys[key]++];
}
When I use the changes shown above, it keeps the order of my custom data arrays. Please let me know what you think.
The text was updated successfully, but these errors were encountered: