npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

enflake

v1.0.6

Published

`Enflake` is a package that alters JavaScript's core built-in standard objects such as `Array.push` and `JSON.parse` in ways that would make them act unreliably without throwing errors nor causing direct exceptions that would make issues traceable to the

Downloads

12

Readme

Enflake

Installation | Configuration | Example | Docs | Contributing

An ~~astonishingly evil~~ entertaining way to wreck havoc in your javascript and typescript projects.

Enflake is a package that alters JavaScript's core built-in standard objects such as Array.push and JSON.parse in ways that would make them act unreliably- ✨ all without throwing errors nor causing direct exceptions that would make issues traceable to the enflake package.

Because Enflake modifies core objects, issues could easily trickle down to other packages and cause fun-to-trace issues over the entire project.

Enflake, by default, allows the flakified methods to act like they normally do most of the time which ensures that ~~problems are only caught when it's already too late~~ projects that use this don't immediately collapse into rubbles.

Selling points

  • turns popular built-in methods into unreliable versions of themselves
  • easy to insert into any js/ts project
  • very subtle
  • untraceable
  • will not cause exceptions that will be traceable to this package

Disclaimer

Using this in production is not a good idea

This package can easily cause issues and was written as a joke so please don't use this in production

Installation

Install the package

npm i enflake
// or you can install it under an alias
npm i axios@npm:enflake

Import the package, preferrably at the top of the main entry file

// if import is supported
import('enflake')
// otherwise, use require
require('enflake')

// if installed under an alias, use that alias
import('axios')
require('axios')

Configuration

There are only two environment variables that can alter how enflake works

  • DEBUG_ENFLAKE [defaults to false]
    • declaring this environment variable will enable logging that will indicate which method is flaking
  • PERCENT_CHANCE_OF_SUCCESS [defaults to 98]
    • Setting this to 100 will ensure that enflake will never cause anything to flake while setting it to 0 will ensure unreliability

Example

require('enflake')

const sampleArray = []
sampleArray.push('a', 'b')
// you may expect sampleArray to now be ['a', 'b']
// but sample array could now be ['a', 'b', 'a'] or ['a', 'b', 'b']
// but note that, by default, it will act as expected 98% of the time

// Check the logs and notice that the results sometimes vary
for(let x = 0; x < 100; x++) {
    console.log(sampleArray)
}

In-depth list of havoc to be caused

JSON

  • JSON.parse(): modifies values depending on their type
    • if value is a string, replace all normal spaces with thin spaces
    • if value is a number, increment or decrement the value
    • if value is a boolean, negate it
    const stringifiedJson = JSON.stringify({
        stringSample: "Enflaked Sample",
        numberSample: 100,
        booleanSample: true
    })
    console.log(JSON.parse(stringifiedJson))
    // expectation: {
    //  stringSample: "Enflaked Sample",
    //  numberSample: 100,
    //  booleanSample: true
    //}
    
    // enflaked result: {
        // this looks like the same string but the space is not really a space but just one that looks like a space.
        // You can verify this by copying the value from the expectation and searching the page for it
    //      stringSample: 'Enflaked Sample',
    //      numberSample: 99,
    //      booleanSample: false
    //  }

Array

  • Array.prototype.at(): will now give you the element at a random index
    const sampleArray = [1,2,3,5,6,11,111]
    console.log(sampleArray.at(1))
    // expectation: 2
    // enflaked result: could be anything in the array
  • Array.prorotype.push(): will modify the pushed value depending on its type
    • if value pushed is a string, the same string will appear in the array twice
    • if value pushed is a number, the number will be incremented
    • if value pushed is a boolean, the value with be negated
    const sampleArray = []
    sampleArray.push(1)
    sampleArray.push("enflake")
    sampleArray.push(trye)
    
    console.log(sampleArray)
    // expectation: [ 1, 'enflake', true ]
    // enflaked result: [ 2, 'enflake', 'enflake', false ]
  • Array.prototype.pop(): will return modified results depending on their type
    • if value popped is a number, the number gets incremented or decremented
    • if value popped is a boolean, the value with be negated
    const sampleArray = [100,true]
    console.log(sampleArray.pop())
    // expectation: true
    // enflaked result: false
    console.log(sampleArray.pop())
    // expectation: 100
    // enflaked result: 99 or 101
  • Array.prototype.every(): will return random results
    const sampleArray = [2,3,4]
    console.log(sampleArray.every((x) => x > 1))
    // expectation: true
    // enflaked result: true or false

Date

  • Date.now(): returns the timestamp for yesterday
    console.log(Date.now())
    // expectation: Today's date (1718201340130)
    // enflaked result: Yesterday's date (1718114940130)

Number

  • Number.prototype.toString(): will return a string version of the incremented/decremented number
    const sampleNumber = 10
    console.log(sampleNumber.toString())
    // expectation: 10
    // enflaked result: 9 or 11

String

  • String.prototype.at(): will return the element at index+-1
    const sampleString = "enflake"
    console.log(sampleString.at(1))
    // expectation: n
    // enflaked result: e or f
  • String.prototype.padStart: will pad the start +-1 of the desired padding
    const sampleString = "enflake"
    console.log(sampleString.padStart(11))
    // expectation: `    enflake`
    // enflaked result: `   enflake` or `     enflake`
  • String.prototype.padEnd: does the same as padStart but for the tail
    const sampleString = "enflake"
    console.log(sampleString.padEnd(11), 'end')
    // expectation: `enflake    end`
    // enflaked result: `enflake   end` or `enflake     end`
  • String.prototype.indexOf: will return -1 even when the element exists in the array
    const sampleString = "enflake"
    console.log(sampleString.indexOf("flake"))
    // expectation: 2
    // enflaked result: -1

Contributing

Contributing is highly welcome- just make sure to follow the following:

  • the effect must be subtle and believable
    • ex:
      • Array.push of a string should not cause an entire object to be pushed
  • in basic cases, the effect must not cause an exception that will lead directly to the library
  • modify the readme to reflect your changes
  • send it in as a pull request

Issues and Requests

Feel free to open issues or request for new features here

License

MIT