Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const fs = require("fs");
const path = require("path");
const tap = require("tap");
const sinon = require("sinon");
const mockfs = require("mock-fs");
const async = require("async");
const iconv = require("iconv-lite");
// Force ICONV to pre-load its encodings
iconv.getCodec("utf8");
// Force babel sub-modules to preload
require("babel-preset-react");
require("babel-helper-builder-react-jsx");
require("babel-plugin-flow-react-proptypes");
require("../lib/babel");
// Load in global ENV
process.env.BASE_DATA_DIR = path.resolve(process.cwd(), "data");
const record = require("../lib/record");
const models = require("../lib/models");
const options = require("../lib/options");
const similarity = require("../lib/similar");
const server = require("../server/server");
process.env.BASE_DATA_DIR = process.cwd();
process.env.PASTEC_URL = "localhost:4212";
process.env.ELASTICSEARCH_URL = "http://localhost:9200";
const fs = require("fs");
const path = require("path");
const tap = require("tap");
const sinon = require("sinon");
const mockfs = require("mock-fs");
const async = require("async");
const iconv = require("iconv-lite");
// Force ICONV to pre-load its encodings
iconv.getCodec("utf8");
// Force babel sub-modules to preload
require("babel-preset-react");
require("babel-helper-builder-react-jsx");
require("babel-register");
const models = require("../lib/models");
const similarity = require("../lib/similar");
const server = require("../server/server");
// Models used for testing
const Image = models("Image");
const Artwork = models("Artwork");
const Source = models("Source");
const ImageImport = models("ImageImport");
const ArtworkImport = models("ArtworkImport");
import iconv from 'iconv-lite'
import filterObj from 'filter-obj'
import { validateCharset } from './validate.js'
import { decodeCharset } from './transform.js'
// `iconv.encodings` is lazily set, i.e. we need to do this noop
iconv.getCodec('binary')
const { encodings } = iconv
// Normalize charset, including adding defaults and validating
export const getCharset = function(charset, { format } = {}) {
const charsetA = addDefaultCharset({ charset, format })
const charsetB = charsetA.toLowerCase()
validateCharset({ charset: charsetB, format })
const charsetC = createInstance({ charset: charsetB, title: charsetA })
return charsetC
}
function getDecoder(encoding) {
if (!encoding) return null
try {
return iconv.getCodec(encoding).decoder()
} catch (e) {
var err = makeError('specified encoding unsupported', 'encoding.unsupported')
err.status = err.statusCode = 415
err.encoding = encoding
throw err
}
}
function getDecoder(encoding) {
if (!encoding) return null
try {
return iconv.getCodec(encoding).decoder()
} catch (e) {
var err = makeError('specified encoding unsupported', 'encoding.unsupported')
err.status = err.statusCode = 415
err.encoding = encoding
throw err
}
}