Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LoaderUtils: Deprecate decodeText(). #28278

Merged
merged 3 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions docs/api/ar/loaders/LoaderUtils.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ <h1>[name]</h1>

<h2>الطرق (Methods)</h2>

<h3>[method:String decodeText]( [param:TypedArray array] )</h3>
<p>[page:TypedArray array] — تدفق بايتات كمصفوفة مكتوبة.</p>
<p>
تأخذ الوظيفة تدفق بايتات كمدخل وتعيد تمثيلًا للسلسلة
</p>

<h3>[method:String extractUrlBase]( [param:String url] )</h3>
<p>[page:String url] — عنوان url الذي سيتم استخراج العنوان الأساسي منه.</p>
<p>استخراج الأساس من عنوان URL.</p>
Expand Down
7 changes: 0 additions & 7 deletions docs/api/en/loaders/LoaderUtils.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ <h1>[name]</h1>

<h2>Functions</h2>

<h3>[method:String decodeText]( [param:TypedArray array] )</h3>
<p>[page:TypedArray array] — A stream of bytes as a typed array.</p>
<p>
The function takes a stream of bytes as input and returns a string
representation.
</p>

<h3>[method:String extractUrlBase]( [param:String url] )</h3>
<p>[page:String url] — The url to extract the base url from.</p>
<p>Extract the base from the URL.</p>
Expand Down
8 changes: 0 additions & 8 deletions docs/api/it/loaders/LoaderUtils.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ <h1>[name]</h1>

<h2>Funzioni</h2>

<h3>[method:String decodeText]( [param:TypedArray array] )</h3>
<p>
[page:TypedArray array] — Uno stream di byte come array tipizzato.
</p>
<p>
La funzione prende uno stream di byte in input e restituisce una rappresentazione di stringa.
</p>

<h3>[method:String extractUrlBase]( [param:String url] )</h3>
<p>
[page:String url] — La url da cui estrarre la url di base.
Expand Down
8 changes: 0 additions & 8 deletions docs/api/zh/loaders/LoaderUtils.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ <h1>[name]</h1>

<h2>函数</h2>

<h3>[method:String decodeText]( [param:TypedArray array] )</h3>
<p>
[page:TypedArray array] — 作为类型化数组的字节流
</p>
<p>
该函数将字节流作为输入并返回字符串作为表示。
</p>

<h3>[method:String extractUrlBase]( [param:String url] )</h3>
<p>
[page:String url] — 从基本URL中,进行提取的URL。
Expand Down
34 changes: 0 additions & 34 deletions src/loaders/LoaderUtils.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,5 @@
class LoaderUtils {

static decodeText( array ) {
ycw marked this conversation as resolved.
Show resolved Hide resolved

if ( typeof TextDecoder !== 'undefined' ) {

return new TextDecoder().decode( array );
ycw marked this conversation as resolved.
Show resolved Hide resolved

}

// Avoid the String.fromCharCode.apply(null, array) shortcut, which
// throws a "maximum call stack size exceeded" error for large arrays.

let s = '';

for ( let i = 0, il = array.length; i < il; i ++ ) {

// Implicitly assumes little-endian.
s += String.fromCharCode( array[ i ] );

}

try {

// merges multi-byte utf-8 characters.

return decodeURIComponent( escape( s ) );

} catch ( e ) { // see #16358

return s;

}

}

static extractUrlBase( url ) {

const index = url.lastIndexOf( '/' );
Expand Down
9 changes: 0 additions & 9 deletions test/unit/src/loaders/LoaderUtils.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@ export default QUnit.module( 'Loaders', () => {
QUnit.module( 'LoaderUtils', () => {

// STATIC
QUnit.test( 'decodeText', ( assert ) => {

const jsonArray = new Uint8Array( [ 123, 34, 106, 115, 111, 110, 34, 58, 32, 116, 114, 117, 101, 125 ] );
assert.equal( '{"json": true}', LoaderUtils.decodeText( jsonArray ) );

const multibyteArray = new Uint8Array( [ 230, 151, 165, 230, 156, 172, 229, 155, 189 ] );
assert.equal( '日本国', LoaderUtils.decodeText( multibyteArray ) );

} );

QUnit.test( 'extractUrlBase', ( assert ) => {

Expand Down
Loading