JSPM

untouched

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q23855F
  • License Unlicense

get pristine copies of built-in objects (like Array or JSON) even if they've been modified

Package Exports

  • untouched

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (untouched) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

untouched

Get pristine copies of built-in objects (like Array or JSON), even if they've been modified. This is generally for library authors who find themselves in monkey-patched browser environments.

Currently only made for browsers. Feel free to submit a Node patch with the vm module!

Here's an example:

// Let's say that someone has messed with the Array prototype.
// If you try to use it, you're screwed!
Array.prototype.map = function () {
  return 'this no longer works'
}

// This will return 'this no longer works'!
var arr = [1, 2, 3]
arr.map(function (n) {
  return n * n
})

// With untouched, you can get around this problem.
// This returns what you expect!
var myUntouched = untouched()
var untouchedArr = new myUntouched('Array')(1, 2, 3)
untouchedArr.map(function (n) {
  return * n
})

// You can use it for things other than Array, too.
var untouchedJson = myUntouched('JSON')
untouchedJson.stringify({ hi: 5 })

We accomplish this by creating a hidden <iframe> and pulling variables out of it. You can remove the iframe whenever you're done with it:

myUntouched.destroy()