Skip to content

Commit

Permalink
Build and version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
idmontie committed Dec 29, 2016
1 parent 973cd6f commit eb1219b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# fake-oranges

[![CircleCI](https://circleci.com/gh/MemosaApp/fake-oranges.svg?style=svg)](https://circleci.com/gh/MemosaApp/fake-oranges)
[![CircleCI](https://circleci.com/gh/MemosaApp/fake-oranges.svg?style=svg)](https://circleci.com/gh/MemosaApp/fake-oranges) [![npm version](https://badge.fury.io/js/fake-oranges.svg)](https://badge.fury.io/js/fake-oranges)

Factory methods for creating fake data

Expand Down
6 changes: 3 additions & 3 deletions dist/factory/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

exports.default = function (originalSchema) {
exports.default = function (originalSchema, offset) {
var generateSchema = function generateSchema(schema, iteration) {
if ((typeof schema === 'undefined' ? 'undefined' : _typeof(schema)) === 'object') {
if (schema !== null && (typeof schema === 'undefined' ? 'undefined' : _typeof(schema)) === 'object') {
var _ret = function () {
var keyPairs = {};

Expand All @@ -32,7 +32,7 @@ exports.default = function (originalSchema) {
return {
generate: function generate(amount) {
return Array.from(Array(amount).keys()).map(function (i) {
return generateSchema(originalSchema, i);
return generateSchema(originalSchema, i + offset);
});
}
};
Expand Down
9 changes: 7 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,19 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
*/
var fake = function fake(schema) {
return {
offset: function offset(_offset) {
this._offset = _offset;
return this;
},
make: function make() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;

var offset = this._offset || 0;
if (amount === 0) {
return (0, _factory2.default)(schema).generate(1)[0];
return (0, _factory2.default)(schema, offset).generate(1)[0];
}

return (0, _factory2.default)(schema).generate(amount);
return (0, _factory2.default)(schema, offset).generate(amount);
}
};
};
Expand Down
30 changes: 30 additions & 0 deletions dist/types/sequential.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
var sequentialBuilder = void 0;
/**
* sequential
*
Expand All @@ -24,6 +25,10 @@ var sequential = function sequential() {
var number = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;

if (number instanceof Array) {
return sequentialBuilder(number, offset);
}

return offset + number;
};

Expand Down Expand Up @@ -55,4 +60,29 @@ sequential.offset = function () {
return s;
};

sequential.loop = function (arr) {
var arrOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;

return sequentialBuilder(arr, arrOffset, true);
};

sequentialBuilder = function sequentialBuilder(arr) {
var arrOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var loop = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;

var extendedSequential = function extendedSequential() {
var number = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;

var index = number + arrOffset + offset;

if (loop) {
index %= arr.length;
}

return index >= arr.length ? null : arr[index];
};
return extendedSequential;
};

exports.default = sequential;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fake-oranges",
"version": "1.0.1",
"version": "1.1.0",
"description": "Quickly generate fake data using data model factories",
"main": "dist/index.js",
"scripts": {
Expand Down

0 comments on commit eb1219b

Please sign in to comment.