![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
`Awry` is a simple little extension to the JavaScript `Array` object to solve the age old debate of whether or not indices should be index `0`, or `1`. `Awry` posits that neither are optimal in every circumstance and allowing the user to change where arra
Awry(1, 2, 3, 4);
Awry
is a simple little extension to the JavaScript Array
object to solve the age old debate of whether or not indices should be index 0
, or 1
. Awry
posits that neither are optimal in every circumstance and allowing the user to change where arrays start may be confusing to readers. When doing computery stuff, we still suggest using index 0
which Awry
obviously supports; BUT when it comes to those icky-squishy humans, Awry
offers an alternative.
const myFavouriteNumbersInAscendingPreferenceOrder = Awry(3, 5, 9, 11);
console.log(`My favourite number is ${myFavouriteNumbersInAscendingPreferenceOrder.first}`);
// -> My favourite number is 3
I hope you can see where we are going with this. All features explained below. But .first
we need to get you up and running.
You can install Awry
into any JavaScript project using any tool that can grab packages from NPM. For examples:
# The NPM package manager (Node's Node Package Manager package manager)
npm i -S 'awrys'
# Yarn (Facebook's Node Package Manager)
yarn i 'awrys'
# PNPM (🔥🔥NPM🔥🔥)
pnpm i 'awrys'
# Bun (🥟)
bun i 'awrys'
We are confident this will be picked up by all the popular CDNs and can be directly injected into your HTML via <script>
tag really soon. The minified size is only 1.96 KB!
Just import or require it. We are only outputting ESM just now because that's all Bun can do and since Bun's release I've forgotten how JavaScript works.
// TypeScript standard
import Awry from 'awrys';
// REPL?
const { Awry } = await import('./build/awry.js');
As alluded to up top, Awry
can do a little more than coolGifs.first
.
Awry
100What if we want to access anything but the first element? Well it may come as no surprise that you can also do the following:
Awry(1, 2, 3, 4).second; // -> 2
Awry(1, 2, 3, 4).third; // -> 3
Awry(1, 2, 3, 4).fourth; // -> 4
Pretty neat huh?!
Awry
101"Four elements? Big whoop! My array has tens of elements". Well not to worry, Awry
has got you there too:
const dopeNumbers = Awry();
for (let x = 1; x <= 37; x++)
dopeNumbers.push(x);
console.log(dopeNumber.twelfth); // -> 12
console.log(dopeNumber.twentyEighth); // -> 28
Now the curious among you might be wondering if I just pre-generated a load of number words and am simply adding them as properties to the 'Awry' object. My sweet summer child no, we like to get a bit more stupid around here. We use Proxy
s! Lets increase the previous example to 1,000 and you can watch in "slow-motion" that something else is at play.
const dopeNumbers = Awry();
for (let x = 1; x <= 1000; x++)
dopeNumbers.push(x);
console.log(dopeNumber.nineHundredAndNinetyNinth); // -> 999
console.log(dopeNumber.oneThousandth); // -> 1000
This took my tired and overworked 5-year-old HP Ultrabook G4 1,848.21ms to run as a Bun test. I'll work on performance once I see how successful this becomes. You can theoretically reference elements by name up-to:
console.log(dopeNumbers.nineHundredAndNinetyNineTrillionNineHundredAndNinetyNineBillionNineHundredAndNinetyNineMillionNineHundredAndNinetyNineThousandNineHundredAndNinetyNinth.toLocaleString('en-GB'));
// -> 999,999,999,999,999 (that's a lot of dope numbers!)
JavaScriptCore can start going a bit weird after that — Not tested outside of Bun. I don't think JavaScript arrays can even have that many elements anyway. And also adding that many properties to an object will take longer than we all have.
sickAssList.last
?What about it? You can do it, you can even go two (or considerably more) steps further. Check this out:
const sickAssList = Awry(1, 2, 3);
console.log(sickAssList.last); // -> 3
console.log(sickAssList.secondLast); // -> 2
console.log(sickAssList.thirdLast); // -> 1
💅
Awry
to a POJSO - what does an Awry
look like?The ordinal properties are not enumerable for reasons but you can see under the bonnet (hood) doing this:
const anotherAwry = Awry(1, 2, 3);
console.log(anotherAwry.toObject());
/* -> {
"0": 1,
"1": 2,
"2": 3,
first: 1,
thirdLast: 1,
second: 2,
secondLast: 2,
third: 3,
last: 3
} */
I genuinely think it might be neat to provide extensions for Array iterator functions that passes the worded ordinal index as a last parameter.
...
FAQs
`Awry` is a simple little extension to the JavaScript `Array` object to solve the age old debate of whether or not indices should be index `0`, or `1`. `Awry` posits that neither are optimal in every circumstance and allowing the user to change where arra
The npm package awrys receives a total of 1 weekly downloads. As such, awrys popularity was classified as not popular.
We found that awrys demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.