At work I don't have dropbox or other 'share my library folder to multiple computers' tool.
I have been meaning to try another project with more dependencies to explore the idea. biga.ahk and most others in my npm profile are basically self-contained.
[Class] biga.ahk (174 utility methods)
Re: [Class] biga.ahk (immutable utility library for arrays, strings, etc)
Last edited by Chunjee on 05 Aug 2021, 14:55, edited 1 time in total.
Re: [Class] biga.ahk (immutable utility library for arrays, strings, etc)
No new version but some existing methods now have documentation:
https://biga-ahk.github.io/biga.ahk/#/?id=isnumber
https://biga-ahk.github.io/biga.ahk/#/?id=isobject
https://biga-ahk.github.io/biga.ahk/#/?id=isstring
https://biga-ahk.github.io/biga.ahk/#/?id=isfloat
https://biga-ahk.github.io/biga.ahk/#/?id=isalnum
https://biga-ahk.github.io/biga.ahk/#/?id=isnumber
https://biga-ahk.github.io/biga.ahk/#/?id=isobject
https://biga-ahk.github.io/biga.ahk/#/?id=isstring
https://biga-ahk.github.io/biga.ahk/#/?id=isfloat
https://biga-ahk.github.io/biga.ahk/#/?id=isalnum
Re: [Class] biga.ahk (immutable utility library for arrays, strings, etc)
v0.42.1
fixes:
.findIndex
.isString
v0.42.2
fixes:
.find
performance enhancements:
.dropWhile .count .filter .find .groupBy .map .partition .reject .some .meanBy .findKey .mapKeys .mapValues .findIndex .dropRight
new:
.isCallable
Please enjoy it
fixes:
.findIndex
.isString
v0.42.2
fixes:
.find
performance enhancements:
.dropWhile .count .filter .find .groupBy .map .partition .reject .some .meanBy .findKey .mapKeys .mapValues .findIndex .dropRight
new:
.isCallable
Code: Select all
boundFunc := Func("strLen").bind()
A.isCallable(boundFunc)
; => true
IsFunc(boundFunc)
; => false
A.isCallable(A.isString)
; => true
A.isCallable(A.matchesProperty("a", 1)
; => true
A.isCallable([1,2,3])
; => false
Please enjoy it
Re: [Class] biga.ahk (immutable utility library for arrays, strings, etc)
For all the methods that can call on a function iteratee; I previously had two or three different checks to see what kind it might be. For example there was a simple isFunc() for straightforward functions, a fn.name check for method calls, and then shorthands turn into boundFuncs were their own challenge. But now basically all of these are discoverable with .isCallable
So the innerworkings have been simplified, meaning they are less prone to edge cases and probably slightly faster.
One complication is that some outputs could be confused by situations where the iteratee is called with the value, key, and collection. for example .trim the 2nd parameter is the characters to trim, and the key would not be useful in that situation and I have "guarded" it. I will be exploring all the methods that need to be guarded and the best way to accomplish that for all necessary methods.
So the innerworkings have been simplified, meaning they are less prone to edge cases and probably slightly faster.
One complication is that some outputs could be confused by situations where the iteratee is called with the value, key, and collection. for example .trim the 2nd parameter is the characters to trim, and the key would not be useful in that situation and I have "guarded" it. I will be exploring all the methods that need to be guarded and the best way to accomplish that for all necessary methods.
Re: [Class] biga.ahk (immutable utility library for arrays, strings, etc)
v0.42.3
fixes:
.findIndex type checking
.find type checking
.keyBy will only use .property shorthand
.difference will remove all occurrences of value
performance enhancements:
.keyBy
.sortBy
.filter
.diffrence was only removing from the array once; whereas it will now remove all occurrences in accordance with the documentation "Creates an array of array values not included in the other given arrays."
Previously:
Now:
fixes:
.findIndex type checking
.find type checking
.keyBy will only use .property shorthand
.difference will remove all occurrences of value
performance enhancements:
.keyBy
.sortBy
.filter
.diffrence was only removing from the array once; whereas it will now remove all occurrences in accordance with the documentation "Creates an array of array values not included in the other given arrays."
Previously:
Code: Select all
A.difference([50, 50, 90], [50])
; => [50, 90]
Code: Select all
A.difference([50, 50, 90], [50])
; => [90]
Last edited by Chunjee on 25 May 2021, 19:04, edited 4 times in total.
Re: [Class] biga.ahk (immutable utility library for arrays, strings, etc)
Added a dark theme to the documentation at https://biga-ahk.github.io/biga.ahk
The default is still light which was updated marginally.
The default is still light which was updated marginally.
Re: [Class] biga.ahk (immutable utility library for arrays, strings, etc)
Pretty chill way to generate an array of random numbers. Without a lot of extra helper functions, variables, outputvars, or while loops; you can control: how many, lower limit, upper limit
Code: Select all
boundFunc := A.random.bind(A, 1, 1000)
array := A.times(5, boundFunc)
; => [395, 364, 809, 904, 449]
Last edited by Chunjee on 28 May 2021, 08:26, edited 1 time in total.
Re: [Class] biga.ahk (immutable utility library for arrays, strings, etc)
v0.43.0
new:
.invert
.invertBy
new:
.invert
.invertBy
Re: [Class] biga.ahk (immutable utility library for arrays, strings, etc)
I converted a modded version of biga.ahk to AHK_H v2 (you may want to create a v2 branch on github)
I wanted the conversion to be totally done automatically, but I had to make a few mods (I used biga.ahk to break and improve ahk_parser.js, so ty)
please test it
og: Biga.ahk
modded: Biga_mid.ahk
converted: Biga.ah2
script that uses it: use biga.ah2
I wanted the conversion to be totally done automatically, but I had to make a few mods (I used biga.ahk to break and improve ahk_parser.js, so ty)
please test it
og: Biga.ahk
modded: Biga_mid.ahk
converted: Biga.ah2
script that uses it: use biga.ah2
Re: [Class] biga.ahk (immutable utility library for arrays, strings, etc)
Thank you that is very much appreciated! I think that is worth linking in the README so that those using v2 can more easily find it.
Re: [Class] biga.ahk (immutable utility library for arrays, strings, etc)
v0.44.0
new:
.isInteger
fixes:
.parseInt more handling of numberlike strings ("10,100", "10 10")
.includes work with object values
new:
.isInteger
fixes:
.parseInt more handling of numberlike strings ("10,100", "10 10")
.includes work with object values
Re: [Class] biga.ahk (immutable utility library for arrays, strings, etc)
v0.44.1
performance:
.isCallable should be slightly faster
fixes:
.sample and .sampleSize will now work with string input. Meaning you can now just write A.sample("123") instead of A.sample(strSplit("123"))
There was a bug when using a guarded message (currently only .trim) when an instance of the class had not been initialized. Now the base class will be checked so that any extending class or fork will work.
Getting closer to a good system to handle more guarded methods.
performance:
.isCallable should be slightly faster
fixes:
.sample and .sampleSize will now work with string input. Meaning you can now just write A.sample("123") instead of A.sample(strSplit("123"))
There was a bug when using a guarded message (currently only .trim) when an instance of the class had not been initialized. Now the base class will be checked so that any extending class or fork will work.
Getting closer to a good system to handle more guarded methods.
Re: [Class] biga.ahk (immutable utility library for arrays, strings, etc)
v0.45.0
new:
.isBoolean
.sumBy
Please enjoy it
new:
.isBoolean
.sumBy
Please enjoy it
Re: [Class] biga.ahk (immutable utility library for arrays, strings, etc)
v0.46.0
new:
.maxBy
.minBy
.pickBy
.countBy
fixes:
.words
Some Documentation typos
Count the word frequency in a long string:
Please enjoy it
new:
.maxBy
.minBy
.pickBy
.countBy
fixes:
.words
Some Documentation typos
Count the word frequency in a long string:
Code: Select all
sentence := "If I remain careful, I can repeat what I am compelled to do, over and over again."
; find how many times each word appears in the sentence
wordOccurances := A.countBy(A.words(sentence), A.toLower)
; => {"again": 1, "am": 1, "and": 1, "can": 1, "careful": 1, "compelled": 1, "do": 1, "i": 3, "if": 1, "over": 2, "remain": 1, "repeat": 1, "to": 1, "what": 1}
Re: [Class] biga.ahk (immutable utility library for arrays, strings, etc)
Thank you for this class and the updates
Re: [Class] biga.ahk (immutable utility library for arrays, strings, etc)
v0.47.0
new:
.identity
.stubArray
.stubFalse
.stubObject
.stubString
.stubTrue
fixes:
.countBy
.every
.findIndex
.findLastIndex
.keyBy
.mapKeys
.mapValues
.maxBy
.meanBy
.minBy
.partition
.pickBy
.sortBy
.sumBy
.times
performance:
.forEach
.invertBy
.keyBy
In the documentation you may have seen "predicate:=.identity" but prior to today this default didn't work on account of .identity not existing. Most of the fixes listed above had to do with making this work for all those methods; but other methods didn't require any code change and are not listed.
Added 24 new unit tests across 22 different methods to ensure .identity always works as a default parameter. This brings the total tests to 632
.identity is a curious method; it just returns the value supplied; not every useful on it's own but since many methods call functions; it can be useful to pass back the called data without any changes.
Create and fill an array:
Since .times uses the .identity as a default iteratee; it can be done the same simply with:
new:
.identity
.stubArray
.stubFalse
.stubObject
.stubString
.stubTrue
fixes:
.countBy
.every
.findIndex
.findLastIndex
.keyBy
.mapKeys
.mapValues
.maxBy
.meanBy
.minBy
.partition
.pickBy
.sortBy
.sumBy
.times
performance:
.forEach
.invertBy
.keyBy
In the documentation you may have seen "predicate:=.identity" but prior to today this default didn't work on account of .identity not existing. Most of the fixes listed above had to do with making this work for all those methods; but other methods didn't require any code change and are not listed.
Added 24 new unit tests across 22 different methods to ensure .identity always works as a default parameter. This brings the total tests to 632
.identity is a curious method; it just returns the value supplied; not every useful on it's own but since many methods call functions; it can be useful to pass back the called data without any changes.
Create and fill an array:
Code: Select all
A.times(10, A.identity)
; => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Code: Select all
A.times(10)
; => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Re: [Class] biga.ahk (utilities mirroring Lodash)
I think removing this superglobal A would be a good idea; which was already in my plan at or around v1.0.0Chunjee wrote: ↑02 Oct 2019, 13:16in v0.3.4 the #Include is now structured
Which means a "superobject" named A will be available at the global scope without creating an instance of biga(). This will continue to exist as a convenience but as a normal practice I would recommend creating an instance of any class you use.Code: Select all
class biga { ; {{methods}} } class A extends biga { ; no changes }
If you disagree please let me know and why.
Re: [Class] biga.ahk (immutable utility library for arrays, strings, etc)
Why would I miss this lib for such a long time. It's so good!
I love it. Thank you for share it!
I love it. Thank you for share it!
Re: [Class] biga.ahk (immutable utility library for arrays, strings, etc)
v0.48.0
new:
.get
fixes:
.inRange
The superglobal A has been removed
new:
.get
fixes:
.inRange
The superglobal A has been removed
Code: Select all
object := {"a": [{ "b": { "c": 3} }]}
A.get(object, "a[1].b.c")
; => 3
A.get(object, ["a", "1", "b", "c"])
; => 3
A.get(object, "a.b.c", "default") ; returns default parameter since no value found at "a.b.c"
; => "default"
Re: [Class] biga.ahk (immutable utility library for arrays, strings, etc)
The library is available for use via the Ace bot and the .ahk command on Discord. Include by using #Include <biga>
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: kiwichick and 73 guests