@cto.af/textdecoder
Advanced tools
Comparing version 0.0.0 to 0.0.1
33
index.js
'use strict' | ||
function add(t, v) { | ||
return t + v | ||
} | ||
let TD = null | ||
@@ -11,18 +15,25 @@ // Note: using globalThis is WAY more complicated than is needed. | ||
TD = window.TextDecoder | ||
} else if (typeof self !== 'undefined') { | ||
// eslint-disable-next-line no-undef | ||
TD = self.TextDecoder | ||
} else { | ||
} else if (typeof self === 'undefined') { | ||
try { | ||
// Node 8.3 - 10 | ||
const util = require('util') | ||
if (process && | ||
process.versions && | ||
process.versions.node && | ||
process.versions.node.match(/^(?:8|10)\./) && | ||
(typeof TD !== 'function')) { | ||
// Let's see if we can fake out the metro bundler. | ||
// The goal is to *not* try to inline the util package here. | ||
const rq = require | ||
const u = ['u', 't', 'i', 'l'].reduce(add, '') | ||
/* istanbul ignore next */ | ||
if (typeof TD !== 'function') { | ||
// node 10 | ||
// Node 8.3 - 10 | ||
// eslint-disable-next-line no-useless-call | ||
const util = rq.call(null, u) | ||
TD = util.TextDecoder | ||
} | ||
} catch (ignored) { | ||
// util couldn't be loaded. Probably an old browser. | ||
// Module util couldn't be loaded. Probably an old browser. | ||
} | ||
} else { | ||
// eslint-disable-next-line no-undef | ||
TD = self.TextDecoder | ||
} | ||
@@ -38,3 +49,3 @@ | ||
decode(buf) { | ||
// this isn't very good, but people should use more modern things | ||
// This isn't very good, but people should use more modern things | ||
// so they don't need it. | ||
@@ -41,0 +52,0 @@ const str = buf.toString(this.utfLabel) |
{ | ||
"name": "@cto.af/textdecoder", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "Quick wrapper that finds TextDecoder or polyfills a bad implementation", | ||
@@ -8,4 +8,4 @@ "main": "index.js", | ||
"test": "node test.js", | ||
"test:all": "nve 4,6,8,10,12,14,15 node test.js", | ||
"lint": "eslint *.js" | ||
"test:all": "nve 4,6,8,10,12,14,16,17 node test.js", | ||
"lint": "eslint . --ext js" | ||
}, | ||
@@ -22,8 +22,11 @@ "repository": "hildjj/ctoaf-textdecoder", | ||
"devDependencies": { | ||
"@cto.af/eslint-config": "^0.0.3", | ||
"eslint": "^7.20.0", | ||
"eslint-plugin-ava": "^11.0.0", | ||
"@cto.af/eslint-config": "^0.0.12", | ||
"eslint": "^8.2.0", | ||
"eslint-plugin-ava": "^13.1.0", | ||
"eslint-plugin-jsdoc": "^37.0.3", | ||
"eslint-plugin-node": "^11.1.0" | ||
}, | ||
"engines": { "node": ">=4.9.1"} | ||
"engines": { | ||
"node": ">=4.9.1" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4147
65
5
2