Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0f6a792

Browse files
committed
Auto-generated commit
1 parent25e9be2 commit0f6a792

File tree

12 files changed

+390
-114
lines changed

12 files changed

+390
-114
lines changed

‎dist/index.js‎

Lines changed: 45 additions & 41 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎dist/index.js.map‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎lib/ctor.js‎

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/**
2+
*@license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MAIN //
22+
23+
/**
24+
* Returns a trap for constructing new array instances.
25+
*
26+
*@private
27+
*@param {Object} ctx - context object
28+
*@param {Function} ctx.array2fancy - function for creating a proxied array
29+
*@returns {Function} handler
30+
*/
31+
functionfactory(ctx){
32+
returnconstructor;
33+
34+
/**
35+
* Trap for constructing new array instances.
36+
*
37+
*@private
38+
*@param {Object} target - target object
39+
*@param {Array} args - list of constructor arguments
40+
*@param {Object} newTarget - constructor that was originally called
41+
*@returns {*} new instance
42+
*/
43+
functionconstructor(target,args){
44+
varx;
45+
vara;
46+
47+
a=args;
48+
switch(a.length){
49+
case0:
50+
x=newtarget();
51+
break;
52+
case1:
53+
x=newtarget(a[0]);
54+
break;
55+
case2:
56+
x=newtarget(a[0],a[1]);
57+
break;
58+
case3:
59+
x=newtarget(a[0],a[1],a[2]);
60+
break;
61+
case4:
62+
x=newtarget(a[0],a[1],a[2],a[3]);
63+
break;
64+
case5:
65+
x=newtarget(a[0],a[1],a[2],a[3],a[4]);
66+
break;
67+
case6:
68+
x=newtarget(a[0],a[1],a[2],a[3],a[4],a[5]);
69+
break;
70+
case7:
71+
x=newtarget(a[0],a[1],a[2],a[3],a[4],a[5],a[6]);
72+
break;
73+
case8:
74+
x=newtarget(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]);
75+
break;
76+
case9:
77+
x=newtarget(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8]);// eslint-disable-line max-len
78+
break;
79+
case10:
80+
x=newtarget(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9]);// eslint-disable-line max-len
81+
break;
82+
default:
83+
// Fallback to using `apply`; however, some constructors may error if the constructor is not callable (i.e., if a constructor always requires `new`):
84+
x=target.apply(null,a);
85+
}
86+
returnctx.array2fancy(x);
87+
}
88+
}
89+
90+
91+
// EXPORTS //
92+
93+
module.exports=factory;

‎lib/get.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ var getSlice = require( './get_slice.js' );
3535
*
3636
*@private
3737
*@param {Object} ctx - context object
38-
*@param {Function} ctx.array2fancy - function for creating a proxied array
3938
*@param {Function} ctx.getter - accessor for retrieving array elements
4039
*@param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking
40+
*@param {Function} ctx.ctor - proxied array constructor
41+
*@param {Function} ctx.postGetSlice - function to process a retrieved slice
4142
*@returns {Function} handler
4243
*/
4344
functionfactory(ctx){
@@ -61,7 +62,7 @@ function factory( ctx ) {
6162
if(hasProperty(target,property)||!isString(property)){
6263
returngetValue(target,property,receiver,ctx);
6364
}
64-
returngetSlice(target,property,receiver,ctx.strict);
65+
returngetSlice(target,property,receiver,ctx);
6566
}
6667
}
6768

‎lib/get_slice.js‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,21 @@ var prop2slice = require( './prop2slice.js' );
3434
*@param {Object} target - target object
3535
*@param {string} property - property name
3636
*@param {Object} receiver - the proxy object or an object inheriting from the proxy
37-
*@param {boolean} strict - boolean indicating whether to enforce strict bounds checking
37+
*@param {Object} ctx - context object
38+
*@param {Function} ctx.postGetSlice - function to process a retrieved slice
39+
*@param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking
3840
*@throws {Error} invalid slice operation
3941
*@throws {RangeError} slice exceeds array bounds
4042
*@returns {(Collection|void)} result
4143
*/
42-
functiongetSlice(target,property,receiver,strict){
43-
vars=prop2slice(target,property,strict);
44+
functiongetSlice(target,property,receiver,ctx){
45+
vars=prop2slice(target,property,ctx.strict);
4446
if(s===null){
4547
// Ensure consistency with normal array behavior by returning `undefined` for any "unrecognized" property name:
4648
return;
4749
}
4850
try{
49-
returnslice(receiver,s,strict);
51+
returnctx.postGetSlice(slice(target,s,ctx.strict));
5052
}catch(err){
5153
// In principle, we should only error when in "strict" mode and a slice exceeds array bounds...
5254
thrownewerr.constructor(errMessage(err.message));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp