@syncfusion/ej2-file-utils
Advanced tools
Comparing version 15.4.17 to 15.4.20
/*! | ||
* filename: ej2-file-utils.umd.min.js | ||
* version : 15.4.17 | ||
* version : 15.4.20 | ||
* Copyright Syncfusion Inc. 2001 - 2017. All rights reserved. | ||
@@ -5,0 +5,0 @@ * Use of this code is subject to the terms of our license. |
@@ -1,2 +0,14 @@ | ||
var Encoding = (function () { | ||
/** | ||
* Encoding class: Contains the details about encoding type, whether to write a Unicode byte order mark (BOM). | ||
* ```typescript | ||
* let encoding : Encoding = new Encoding(); | ||
* encoding.type = 'Utf8'; | ||
* encoding.getBytes('Encoding', 0, 5); | ||
* ``` | ||
*/ | ||
var Encoding = /** @class */ (function () { | ||
/** | ||
* Initializes a new instance of the Encoding class. A parameter specifies whether to write a Unicode byte order mark | ||
* @param {boolean} includeBom?-true to specify that a Unicode byte order mark is written; otherwise, false. | ||
*/ | ||
function Encoding(includeBom) { | ||
@@ -8,2 +20,6 @@ this.emitBOM = true; | ||
Object.defineProperty(Encoding.prototype, "includeBom", { | ||
/** | ||
* Gets a value indicating whether to write a Unicode byte order mark | ||
* @returns boolean- true to specify that a Unicode byte order mark is written; otherwise, false | ||
*/ | ||
get: function () { | ||
@@ -16,5 +32,13 @@ return this.emitBOM; | ||
Object.defineProperty(Encoding.prototype, "type", { | ||
/** | ||
* Gets the encoding type. | ||
* @returns EncodingType | ||
*/ | ||
get: function () { | ||
return this.encodingType; | ||
}, | ||
/** | ||
* Sets the encoding type. | ||
* @param {EncodingType} value | ||
*/ | ||
set: function (value) { | ||
@@ -26,2 +50,6 @@ this.encodingType = value; | ||
}); | ||
/** | ||
* Initialize the includeBom to emit BOM or Not | ||
* @param {boolean} includeBom | ||
*/ | ||
Encoding.prototype.initBOM = function (includeBom) { | ||
@@ -35,2 +63,7 @@ if (includeBom === undefined || includeBom === null) { | ||
}; | ||
/** | ||
* Calculates the number of bytes produced by encoding the characters in the specified string | ||
* @param {string} chars - The string containing the set of characters to encode | ||
* @returns {number} - The number of bytes produced by encoding the specified characters | ||
*/ | ||
Encoding.prototype.getByteCount = function (chars) { | ||
@@ -48,2 +81,7 @@ var byteCount = 0; | ||
}; | ||
/** | ||
* Return the Byte of character | ||
* @param {number} codePoint | ||
* @returns {number} | ||
*/ | ||
Encoding.prototype.utf8Len = function (codePoint) { | ||
@@ -56,5 +94,15 @@ var bytes = codePoint <= 0x7F ? 1 : | ||
}; | ||
/** | ||
* for 4 byte character return surrogate pair true, otherwise false | ||
* @param {number} codeUnit | ||
* @returns {boolean} | ||
*/ | ||
Encoding.prototype.isHighSurrogate = function (codeUnit) { | ||
return codeUnit >= 0xD800 && codeUnit <= 0xDBFF; | ||
}; | ||
/** | ||
* for 4byte character generate the surrogate pair | ||
* @param {number} highCodeUnit | ||
* @param {number} lowCodeUnit | ||
*/ | ||
Encoding.prototype.toCodepoint = function (highCodeUnit, lowCodeUnit) { | ||
@@ -65,2 +113,8 @@ highCodeUnit = (0x3FF & highCodeUnit) << 10; | ||
}; | ||
/** | ||
* private method to get the byte count for specific charindex and count | ||
* @param {string} chars | ||
* @param {number} charIndex | ||
* @param {number} charCount | ||
*/ | ||
Encoding.prototype.getByteCountInternal = function (chars, charIndex, charCount) { | ||
@@ -102,2 +156,9 @@ var byteCount = 0; | ||
}; | ||
/** | ||
* Encodes a set of characters from the specified string into the ArrayBuffer. | ||
* @param {string} s- The string containing the set of characters to encode | ||
* @param {number} charIndex-The index of the first character to encode. | ||
* @param {number} charCount- The number of characters to encode. | ||
* @returns {ArrayBuffer} - The ArrayBuffer that contains the resulting sequence of bytes. | ||
*/ | ||
Encoding.prototype.getBytes = function (s, charIndex, charCount) { | ||
@@ -134,2 +195,9 @@ validateNullOrUndefined(s, 'string'); | ||
}; | ||
/** | ||
* Decodes a sequence of bytes from the specified ArrayBuffer into the string. | ||
* @param {ArrayBuffer} bytes- The ArrayBuffer containing the sequence of bytes to decode. | ||
* @param {number} index- The index of the first byte to decode. | ||
* @param {number} count- The number of bytes to decode. | ||
* @returns {string} - The string that contains the resulting set of characters. | ||
*/ | ||
Encoding.prototype.getString = function (bytes, index, count) { | ||
@@ -165,3 +233,3 @@ validateNullOrUndefined(bytes, 'bytes'); | ||
var c = byteCal[j]; | ||
out += String.fromCharCode(c); | ||
out += String.fromCharCode(c); // 1 byte(ASCII) character | ||
j++; | ||
@@ -182,3 +250,3 @@ } | ||
else { | ||
bufview[k] = 63; | ||
bufview[k] = 63; //replacement character '?' | ||
} | ||
@@ -211,3 +279,3 @@ k++; | ||
uint[++j] = 0xbf; | ||
uint[++j] = 0xbd; | ||
uint[++j] = 0xbd; // U+FFFE "replacement character" | ||
} | ||
@@ -249,3 +317,3 @@ ++j; | ||
} | ||
s += String.fromCharCode(c); | ||
s += String.fromCharCode(c); // 1 byte(ASCII) character | ||
} | ||
@@ -266,2 +334,6 @@ return s; | ||
}; | ||
/** | ||
* To clear the encoding instance | ||
* @return {void} | ||
*/ | ||
Encoding.prototype.destroy = function () { | ||
@@ -274,2 +346,9 @@ this.emitBOM = undefined; | ||
export { Encoding }; | ||
/** | ||
* To check the object is null or undefined and throw error if it is null or undefined | ||
* @param {Object} value - object to check is null or undefined | ||
* @return {boolean} | ||
* @throws {ArgumentException} - if the value is null or undefined | ||
* @private | ||
*/ | ||
export function validateNullOrUndefined(value, message) { | ||
@@ -276,0 +355,0 @@ if (value === null || value === undefined) { |
@@ -0,3 +1,8 @@ | ||
// export all modules from current location | ||
// example: export * from './module' | ||
/** | ||
* file utils modules | ||
*/ | ||
export * from './stream-writer'; | ||
export * from './encoding'; | ||
export * from './save'; |
@@ -1,4 +0,21 @@ | ||
var Save = (function () { | ||
/** | ||
* Save class provide method to save file | ||
* ```typescript | ||
* let blob : Blob = new Blob([''], { type: 'text/plain' }); | ||
* Save.save('fileName.txt',blob); | ||
*/ | ||
var Save = /** @class */ (function () { | ||
/** | ||
* Initialize new instance of {save} | ||
*/ | ||
function Save() { | ||
// tslint:disable | ||
} | ||
/** | ||
* Saves the file with specified name and sends the file to client browser | ||
* @param {string} fileName- file name to save. | ||
* @param {Blob} buffer- the content to write in file | ||
* @param {boolean} isMicrosoftBrowser- specify whether microsoft browser or not | ||
* @returns {void} | ||
*/ | ||
Save.save = function (fileName, buffer) { | ||
@@ -54,2 +71,7 @@ if (fileName === null || fileName === undefined || fileName === '') { | ||
}; | ||
/** | ||
* | ||
* @param {string} extension - get mime type of the specified extension | ||
* @private | ||
*/ | ||
Save.getMimeType = function (extension) { | ||
@@ -56,0 +78,0 @@ var mimeType = ''; |
import { Encoding, validateNullOrUndefined } from './encoding'; | ||
import { Save } from './save'; | ||
var StreamWriter = (function () { | ||
/** | ||
* StreamWriter class contains the implementation for writing characters to a file in a particular encoding | ||
* ```typescript | ||
* let writer = new StreamWriter(); | ||
* writer.write('Hello World'); | ||
* writer.save('Sample.txt'); | ||
* writer.dispose(); | ||
* ``` | ||
*/ | ||
var StreamWriter = /** @class */ (function () { | ||
/** | ||
* Initializes a new instance of the StreamWriter class by using the specified encoding. | ||
* @param {Encoding} encoding?- The character encoding to use. | ||
*/ | ||
function StreamWriter(encoding) { | ||
@@ -11,2 +24,6 @@ this.bufferBlob = new Blob(['']); | ||
Object.defineProperty(StreamWriter.prototype, "buffer", { | ||
/** | ||
* Gets the content written to the StreamWriter as Blob. | ||
* @returns Blob | ||
*/ | ||
get: function () { | ||
@@ -20,2 +37,6 @@ this.flush(); | ||
Object.defineProperty(StreamWriter.prototype, "encoding", { | ||
/** | ||
* Gets the encoding. | ||
* @returns Encoding | ||
*/ | ||
get: function () { | ||
@@ -37,2 +58,5 @@ return this.enc; | ||
}; | ||
/** | ||
* Private method to set Byte Order Mark(BOM) value based on EncodingType | ||
*/ | ||
StreamWriter.prototype.setBomByte = function () { | ||
@@ -62,2 +86,7 @@ if (this.encoding.includeBom) { | ||
}; | ||
/** | ||
* Saves the file with specified name and sends the file to client browser | ||
* @param {string} fileName - The file name to save | ||
* @returns {void} | ||
*/ | ||
StreamWriter.prototype.save = function (fileName) { | ||
@@ -69,2 +98,7 @@ if (this.bufferText !== '') { | ||
}; | ||
/** | ||
* Writes the specified string. | ||
* @param {string} value - The string to write. If value is null or undefined, nothing is written. | ||
* @returns {void} | ||
*/ | ||
StreamWriter.prototype.write = function (value) { | ||
@@ -88,2 +122,7 @@ if (this.encoding === undefined) { | ||
}; | ||
/** | ||
* Writes the specified string followed by a line terminator | ||
* @param {string} value - The string to write. If value is null or undefined, nothing is written | ||
* @returns {void} | ||
*/ | ||
StreamWriter.prototype.writeLine = function (value) { | ||
@@ -99,2 +138,6 @@ if (this.encoding === undefined) { | ||
}; | ||
/** | ||
* Releases the resources used by the StreamWriter | ||
* @returns {void} | ||
*/ | ||
StreamWriter.prototype.destroy = function () { | ||
@@ -101,0 +144,0 @@ this.bufferBlob = undefined; |
{ | ||
"name": "@syncfusion/ej2-file-utils", | ||
"version": "15.4.17", | ||
"version": "15.4.20", | ||
"description": "Essential JS 2 File Library", | ||
@@ -5,0 +5,0 @@ "author": "Syncfusion Inc.", |
Sorry, the diff of this file is not supported yet
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
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
150378
1877