mirror of
https://github.com/musix-org/musix-oss
synced 2025-06-17 01:16:00 +00:00
Modules
This commit is contained in:
1
node_modules/encoding/.npmignore
generated
vendored
Normal file
1
node_modules/encoding/.npmignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
25
node_modules/encoding/.travis.yml
generated
vendored
Normal file
25
node_modules/encoding/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
language: node_js
|
||||
sudo: false
|
||||
node_js:
|
||||
- "0.10"
|
||||
- 0.12
|
||||
- iojs
|
||||
- 4
|
||||
- 5
|
||||
env:
|
||||
- CXX=g++-4.8
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-4.8
|
||||
notifications:
|
||||
email:
|
||||
- andris@kreata.ee
|
||||
webhooks:
|
||||
urls:
|
||||
- https://webhooks.gitter.im/e/0ed18fd9b3e529b3c2cc
|
||||
on_success: change # options: [always|never|change] default: always
|
||||
on_failure: always # options: [always|never|change] default: always
|
||||
on_start: false # default: false
|
16
node_modules/encoding/LICENSE
generated
vendored
Normal file
16
node_modules/encoding/LICENSE
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
Copyright (c) 2012-2014 Andris Reinman
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
52
node_modules/encoding/README.md
generated
vendored
Normal file
52
node_modules/encoding/README.md
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
# Encoding
|
||||
|
||||
**encoding** is a simple wrapper around [node-iconv](https://github.com/bnoordhuis/node-iconv) and [iconv-lite](https://github.com/ashtuchkin/iconv-lite/) to convert strings from one encoding to another. If node-iconv is not available for some reason,
|
||||
iconv-lite will be used instead of it as a fallback.
|
||||
|
||||
[](http://travis-ci.org/andris9/Nodemailer)
|
||||
[](http://badge.fury.io/js/encoding)
|
||||
|
||||
## Install
|
||||
|
||||
Install through npm
|
||||
|
||||
npm install encoding
|
||||
|
||||
## Usage
|
||||
|
||||
Require the module
|
||||
|
||||
var encoding = require("encoding");
|
||||
|
||||
Convert with encoding.convert()
|
||||
|
||||
var resultBuffer = encoding.convert(text, toCharset, fromCharset);
|
||||
|
||||
Where
|
||||
|
||||
* **text** is either a Buffer or a String to be converted
|
||||
* **toCharset** is the characterset to convert the string
|
||||
* **fromCharset** (*optional*, defaults to UTF-8) is the source charset
|
||||
|
||||
Output of the conversion is always a Buffer object.
|
||||
|
||||
Example
|
||||
|
||||
var result = encoding.convert("ÕÄÖÜ", "Latin_1");
|
||||
console.log(result); //<Buffer d5 c4 d6 dc>
|
||||
|
||||
## iconv support
|
||||
|
||||
By default only iconv-lite is bundled. If you need node-iconv support, you need to add it
|
||||
as an additional dependency for your project:
|
||||
|
||||
...,
|
||||
"dependencies":{
|
||||
"encoding": "*",
|
||||
"iconv": "*"
|
||||
},
|
||||
...
|
||||
|
||||
## License
|
||||
|
||||
**MIT**
|
113
node_modules/encoding/lib/encoding.js
generated
vendored
Normal file
113
node_modules/encoding/lib/encoding.js
generated
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
'use strict';
|
||||
|
||||
var iconvLite = require('iconv-lite');
|
||||
// Load Iconv from an external file to be able to disable Iconv for webpack
|
||||
// Add /\/iconv-loader$/ to webpack.IgnorePlugin to ignore it
|
||||
var Iconv = require('./iconv-loader');
|
||||
|
||||
// Expose to the world
|
||||
module.exports.convert = convert;
|
||||
|
||||
/**
|
||||
* Convert encoding of an UTF-8 string or a buffer
|
||||
*
|
||||
* @param {String|Buffer} str String to be converted
|
||||
* @param {String} to Encoding to be converted to
|
||||
* @param {String} [from='UTF-8'] Encoding to be converted from
|
||||
* @param {Boolean} useLite If set to ture, force to use iconvLite
|
||||
* @return {Buffer} Encoded string
|
||||
*/
|
||||
function convert(str, to, from, useLite) {
|
||||
from = checkEncoding(from || 'UTF-8');
|
||||
to = checkEncoding(to || 'UTF-8');
|
||||
str = str || '';
|
||||
|
||||
var result;
|
||||
|
||||
if (from !== 'UTF-8' && typeof str === 'string') {
|
||||
str = new Buffer(str, 'binary');
|
||||
}
|
||||
|
||||
if (from === to) {
|
||||
if (typeof str === 'string') {
|
||||
result = new Buffer(str);
|
||||
} else {
|
||||
result = str;
|
||||
}
|
||||
} else if (Iconv && !useLite) {
|
||||
try {
|
||||
result = convertIconv(str, to, from);
|
||||
} catch (E) {
|
||||
console.error(E);
|
||||
try {
|
||||
result = convertIconvLite(str, to, from);
|
||||
} catch (E) {
|
||||
console.error(E);
|
||||
result = str;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
result = convertIconvLite(str, to, from);
|
||||
} catch (E) {
|
||||
console.error(E);
|
||||
result = str;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (typeof result === 'string') {
|
||||
result = new Buffer(result, 'utf-8');
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert encoding of a string with node-iconv (if available)
|
||||
*
|
||||
* @param {String|Buffer} str String to be converted
|
||||
* @param {String} to Encoding to be converted to
|
||||
* @param {String} [from='UTF-8'] Encoding to be converted from
|
||||
* @return {Buffer} Encoded string
|
||||
*/
|
||||
function convertIconv(str, to, from) {
|
||||
var response, iconv;
|
||||
iconv = new Iconv(from, to + '//TRANSLIT//IGNORE');
|
||||
response = iconv.convert(str);
|
||||
return response.slice(0, response.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert encoding of astring with iconv-lite
|
||||
*
|
||||
* @param {String|Buffer} str String to be converted
|
||||
* @param {String} to Encoding to be converted to
|
||||
* @param {String} [from='UTF-8'] Encoding to be converted from
|
||||
* @return {Buffer} Encoded string
|
||||
*/
|
||||
function convertIconvLite(str, to, from) {
|
||||
if (to === 'UTF-8') {
|
||||
return iconvLite.decode(str, from);
|
||||
} else if (from === 'UTF-8') {
|
||||
return iconvLite.encode(str, to);
|
||||
} else {
|
||||
return iconvLite.encode(iconvLite.decode(str, from), to);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts charset name if needed
|
||||
*
|
||||
* @param {String} name Character set
|
||||
* @return {String} Character set name
|
||||
*/
|
||||
function checkEncoding(name) {
|
||||
return (name || '').toString().trim().
|
||||
replace(/^latin[\-_]?(\d+)$/i, 'ISO-8859-$1').
|
||||
replace(/^win(?:dows)?[\-_]?(\d+)$/i, 'WINDOWS-$1').
|
||||
replace(/^utf[\-_]?(\d+)$/i, 'UTF-$1').
|
||||
replace(/^ks_c_5601\-1987$/i, 'CP949').
|
||||
replace(/^us[\-_]?ascii$/i, 'ASCII').
|
||||
toUpperCase();
|
||||
}
|
14
node_modules/encoding/lib/iconv-loader.js
generated
vendored
Normal file
14
node_modules/encoding/lib/iconv-loader.js
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
var iconv_package;
|
||||
var Iconv;
|
||||
|
||||
try {
|
||||
// this is to fool browserify so it doesn't try (in vain) to install iconv.
|
||||
iconv_package = 'iconv';
|
||||
Iconv = require(iconv_package).Iconv;
|
||||
} catch (E) {
|
||||
// node-iconv not present
|
||||
}
|
||||
|
||||
module.exports = Iconv;
|
56
node_modules/encoding/package.json
generated
vendored
Normal file
56
node_modules/encoding/package.json
generated
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"encoding@0.1.12",
|
||||
"C:\\Users\\matia\\Musix"
|
||||
]
|
||||
],
|
||||
"_from": "encoding@0.1.12",
|
||||
"_id": "encoding@0.1.12",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=",
|
||||
"_location": "/encoding",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "encoding@0.1.12",
|
||||
"name": "encoding",
|
||||
"escapedName": "encoding",
|
||||
"rawSpec": "0.1.12",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "0.1.12"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/node-fetch"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz",
|
||||
"_spec": "0.1.12",
|
||||
"_where": "C:\\Users\\matia\\Musix",
|
||||
"author": {
|
||||
"name": "Andris Reinman"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/andris9/encoding/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"iconv-lite": "~0.4.13"
|
||||
},
|
||||
"description": "Convert encodings, uses iconv by default and fallbacks to iconv-lite if needed",
|
||||
"devDependencies": {
|
||||
"iconv": "~2.1.11",
|
||||
"nodeunit": "~0.9.1"
|
||||
},
|
||||
"homepage": "https://github.com/andris9/encoding#readme",
|
||||
"license": "MIT",
|
||||
"main": "lib/encoding.js",
|
||||
"name": "encoding",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/andris9/encoding.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "nodeunit test"
|
||||
},
|
||||
"version": "0.1.12"
|
||||
}
|
75
node_modules/encoding/test/test.js
generated
vendored
Normal file
75
node_modules/encoding/test/test.js
generated
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
'use strict';
|
||||
|
||||
var Iconv = require('../lib/iconv-loader');
|
||||
var encoding = require('../lib/encoding');
|
||||
|
||||
exports['General tests'] = {
|
||||
|
||||
'Iconv is available': function (test) {
|
||||
test.ok(Iconv);
|
||||
test.done();
|
||||
},
|
||||
|
||||
'From UTF-8 to Latin_1 with Iconv': function (test) {
|
||||
var input = 'ÕÄÖÜ',
|
||||
expected = new Buffer([0xd5, 0xc4, 0xd6, 0xdc]);
|
||||
test.deepEqual(encoding.convert(input, 'latin1'), expected);
|
||||
test.done();
|
||||
},
|
||||
|
||||
'From Latin_1 to UTF-8 with Iconv': function (test) {
|
||||
var input = new Buffer([0xd5, 0xc4, 0xd6, 0xdc]),
|
||||
expected = 'ÕÄÖÜ';
|
||||
test.deepEqual(encoding.convert(input, 'utf-8', 'latin1').toString(), expected);
|
||||
test.done();
|
||||
},
|
||||
|
||||
'From UTF-8 to UTF-8 with Iconv': function (test) {
|
||||
var input = 'ÕÄÖÜ',
|
||||
expected = new Buffer('ÕÄÖÜ');
|
||||
test.deepEqual(encoding.convert(input, 'utf-8', 'utf-8'), expected);
|
||||
test.done();
|
||||
},
|
||||
|
||||
'From Latin_13 to Latin_15 with Iconv': function (test) {
|
||||
var input = new Buffer([0xd5, 0xc4, 0xd6, 0xdc, 0xd0]),
|
||||
expected = new Buffer([0xd5, 0xc4, 0xd6, 0xdc, 0xA6]);
|
||||
test.deepEqual(encoding.convert(input, 'latin_15', 'latin13'), expected);
|
||||
test.done();
|
||||
},
|
||||
|
||||
'From ISO-2022-JP to UTF-8 with Iconv': function (test) {
|
||||
var input = new Buffer('GyRCM1g5OzU7PVEwdzgmPSQ4IUYkMnFKczlwGyhC', 'base64'),
|
||||
expected = new Buffer('5a2m5qCh5oqA6KGT5ZOh56CU5L+u5qSc6KiO5Lya5aCx5ZGK', 'base64');
|
||||
test.deepEqual(encoding.convert(input, 'utf-8', 'ISO-2022-JP'), expected);
|
||||
test.done();
|
||||
},
|
||||
|
||||
'From UTF-8 to Latin_1 with iconv-lite': function (test) {
|
||||
var input = 'ÕÄÖÜ',
|
||||
expected = new Buffer([0xd5, 0xc4, 0xd6, 0xdc]);
|
||||
test.deepEqual(encoding.convert(input, 'latin1', false, true), expected);
|
||||
test.done();
|
||||
},
|
||||
|
||||
'From Latin_1 to UTF-8 with iconv-lite': function (test) {
|
||||
var input = new Buffer([0xd5, 0xc4, 0xd6, 0xdc]),
|
||||
expected = 'ÕÄÖÜ';
|
||||
test.deepEqual(encoding.convert(input, 'utf-8', 'latin1', true).toString(), expected);
|
||||
test.done();
|
||||
},
|
||||
|
||||
'From UTF-8 to UTF-8 with iconv-lite': function (test) {
|
||||
var input = 'ÕÄÖÜ',
|
||||
expected = new Buffer('ÕÄÖÜ');
|
||||
test.deepEqual(encoding.convert(input, 'utf-8', 'utf-8', true), expected);
|
||||
test.done();
|
||||
},
|
||||
|
||||
'From Latin_13 to Latin_15 with iconv-lite': function (test) {
|
||||
var input = new Buffer([0xd5, 0xc4, 0xd6, 0xdc, 0xd0]),
|
||||
expected = new Buffer([0xd5, 0xc4, 0xd6, 0xdc, 0xA6]);
|
||||
test.deepEqual(encoding.convert(input, 'latin_15', 'latin13', true), expected);
|
||||
test.done();
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user