Added a test command and added npm stuff
This commit is contained in:
parent
c01f1ce27b
commit
f4e1426efe
7
LICENSE.md
Normal file
7
LICENSE.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
20
index.js
20
index.js
|
@ -10,13 +10,15 @@ var names = [];
|
|||
var stars = [];
|
||||
var planets = [];
|
||||
|
||||
function generate() {
|
||||
function generate(seed, amount) {
|
||||
if (!amount) amount = 1000;
|
||||
if (!seed) seed = 1234;
|
||||
var spiral_arms = 2, spiral_angle_degrees = 360, min_radius = 0.05, max_radius = 0.9, thickness = 0.1, scatter_theta = Math.PI / spiral_arms * 0.2, scatter_radius = min_radius * 0.4, spiral_b = spiral_angle_degrees / Math.PI * min_radius / max_radius, start = (new Date()).getTime(), names = [], rejects = {
|
||||
badwords: 0,
|
||||
duplicates: 0
|
||||
}, totalCount = 1000, i, position;
|
||||
}, totalCount = amount, i, position;
|
||||
|
||||
pseudoRandom = new PRNG('96aa48');
|
||||
pseudoRandom = new PRNG(seed);
|
||||
|
||||
for (i = 0; i < totalCount; i++) {
|
||||
var number_of_syllables = Math.floor(pseudoRandom.value() * 2 + 2), new_name;
|
||||
|
@ -55,11 +57,13 @@ function generate() {
|
|||
Object.assign(star, star.description());
|
||||
}
|
||||
|
||||
fs.writeFileSync(__dirname + '/galaxy.json', JSON.stringify(stars, null, 2))
|
||||
return stars;
|
||||
// fs.writeFileSync(__dirname + '/galaxy.json', JSON.stringify(stars, null, 2))
|
||||
|
||||
|
||||
console.log('names rejected', rejects);
|
||||
console.log('generate elapsed', (((new Date()).getTime() - start) * 0.001).toFixed(3) + "s");
|
||||
// console.log('names rejected', rejects);
|
||||
// console.log('generate elapsed', (((new Date()).getTime() - start) * 0.001).toFixed(3) + "s");
|
||||
}
|
||||
|
||||
generate();
|
||||
module.exports = {
|
||||
"generate": generate
|
||||
}
|
||||
|
|
27
package.json
Normal file
27
package.json
Normal file
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"name": "galaxygen",
|
||||
"version": "1.0.0",
|
||||
"description": "A galaxy generator based on loewald.com/galaxy",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "node index test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/96aa48/galaxygen.git"
|
||||
},
|
||||
"keywords": [
|
||||
"galaxy",
|
||||
"generator",
|
||||
"loewald",
|
||||
"lore",
|
||||
"universe",
|
||||
"prng"
|
||||
],
|
||||
"author": "Bram van der Veen",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/96aa48/galaxygen/issues"
|
||||
},
|
||||
"homepage": "https://github.com/96aa48/galaxygen#readme"
|
||||
}
|
Reference in a new issue