waifu-generator
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -25,3 +25,3 @@ const https = require('https'); | ||
new Promise((resolve, reject) => { | ||
const { filename = null, path = null, skipFs = false } = { ...options } | ||
const { filename = null, path = null, skipFs = false } = { ...options }; | ||
const randomNumber = Math.floor(Math.random() * 100000); | ||
@@ -56,3 +56,3 @@ const imgSource = `https://www.thiswaifudoesnotexist.net/example-${randomNumber}.jpg`; | ||
} | ||
} | ||
}; | ||
@@ -67,6 +67,6 @@ const options = handleOptions(); | ||
); | ||
} | ||
}; | ||
}); | ||
}) | ||
}); | ||
module.exports = generateWaifu; |
{ | ||
"name": "waifu-generator", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Scrap random anime girls from thiswaifudoesnotexist.net", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# waifu-generator | ||
<p align="center"> | ||
<a href="https://www.deviantart.com/icw-numen/art/JavaScript-chan-762039250"> | ||
<img width="300" src="https://i.ibb.co/VWHXh3F/javascriptchan.png"> | ||
</a> | ||
</p> | ||
@@ -14,3 +16,3 @@ <p align="center"> | ||
# Usecase ? | ||
You need to generate random pictures files for testing purposes, but [js-image-generator](https://www.npmjs.com/package/js-image-generator) is definitely too efficient and boring for the job? | ||
You need to generate random pngs for testing purposes, but [js-image-generator](https://www.npmjs.com/package/js-image-generator) is definitely too efficient and boring for the job? | ||
@@ -20,3 +22,3 @@ Look no further! TheRealBarenziah(tm) brings you this StyleGAN2-empowered[*](#BTW),industrial grade, uwu-compliant, yet unlicensed module! | ||
# Compatibility | ||
**node >= 8** (we're using [fs](https://nodejs.org/api/fs.html) and [promises](https://node.green/)) | ||
**node >= 8** (we're using [promises](https://node.green/)) | ||
@@ -34,3 +36,3 @@ # Use | ||
.then(res => console.log(res)) | ||
.catch(e => console.error(e)) | ||
.catch(e => console.error(e)); | ||
``` | ||
@@ -41,12 +43,12 @@ Back in terminal (for the example): | ||
# ...will write a random image file in cwd (current working directory). | ||
# The filename will follow the pattern "$imageId_$uuid.jpg", | ||
# The filename will follow the pattern "$imageId_$uuid.png", | ||
# where $imageId is the image id for thiswaifudoesnotexist.net, | ||
# and $uuid is some uuidv4 generated on the fly | ||
# and $uuid some uuidv4 generated on the fly | ||
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII= | ||
# Since we log the return value with .then(res => console.log(res)) | ||
# Since we logged the return value with .then(res => console.log(res)) | ||
# a base64 string representation of our image is printed in stdout. | ||
# It is facultative but may come in handy. Check the string by copypasting it into your favorite browser, | ||
# or whatever. Just know it's there, in the resolve value ! | ||
# It is facultative, but may come in handy. You can check the string by copypasting it | ||
# into your favorite browser, or whatever. Just know it's there, in the resolve value ! | ||
``` | ||
@@ -61,3 +63,3 @@ ### Case 2 : providing an option object | ||
path: "./__TESTS__/images" | ||
} | ||
}; | ||
@@ -70,6 +72,7 @@ generateWaifu(options); | ||
# ...will write a random image file in "./__TESTS__/images", | ||
# with "sugoi_kawaii.jpg" as its filename. | ||
# No output in stdout since we didn't explicitely '.then(res => console.log(res));' | ||
# with "sugoi_kawaii.png" as its filename. | ||
# | ||
# No output since we didn't explicitely '.then(res => console.log(res));' | ||
``` | ||
**NB: `options` object is facultative; `options.filename` and `options.path` [default to null](https://github.com/TheRealBarenziah/waifu-generator/blob/senpai/index.js#L22), while `options.skipFs` default to false**. | ||
**NB: `options` object is facultative; `options.filename` and `options.path` default to null; `options.skipFs` default to false**. | ||
@@ -80,3 +83,3 @@ **You can pass a single option:** providing a `filename` but no `path`, the `path` will default to root. | ||
### Case 2.5: skip the fs call | ||
Sometimes, you don't want your tests doing I/O operations (mainly, when needing performance). In that case, you can chose to skip the call to filesystem entierely, leaving you to work with pure base64 strings, ready to be allocated. | ||
Sometimes, you don't want your tests to do I/O operations (typically when you're after performance). In that case you can skip the filesystem call entierely, leaving you to work with pure base64 strings, ready to be allocated. | ||
@@ -92,8 +95,8 @@ Barebone example: | ||
.then(res => this.base64waifu = res) | ||
.catch(e => e) | ||
.catch(e => e); | ||
const output = this.base64waifu.toString().toString().toString(); | ||
// Dumb example of arbitrary filth you're free to inflict to your base64 waifu here | ||
// Example of arbitrary filth you're free to inflict to your base64 waifu here | ||
console.log(output); // printing stuff, as promise is resolved already | ||
console.log(output); // printing our stuff | ||
return output; | ||
@@ -110,3 +113,3 @@ }; | ||
Of course you're also free to skip the hassle by using the `skipFs` parameter ! | ||
..Of course you're also free to skip the hassle by using the `skipFs` parameter ! | ||
@@ -113,0 +116,0 @@ Take advantage of this module being unlicensed: please fork away and write the best solution for your specific need :) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
110
9609