Created by: joshterrill
This is my first PR for this repo, I thought this issue would be a good one to get started on. This resolves issue #1357 and adds an optional parameter for sending through a sizeLimit
parameter on opts
when creating a job. If the data you're sending through is larger than the sizeLimit
set, an exception is thrown.
A couple of notes:
-
I added a dependency called
bytes
which is a small dependency which allows a user to type a "human readable"sizeLimit
such as1b
,1mb
,1gb
, etc. instead of having to convert everything to bytes themselves. I also added a utility function so that a user can either set the limit as a number in bytes, or the human readable format. If you don't want this other dependency there, let me know and I can make it so that it'll just take the number in bytes that a user types in. -
I implemented a utility function that I saw on this stack overflow post that describes how to count the size of strings, which also include non-ascii characters. Just to be safe, and to support other character encodings, I use this method to calculate the size.