1+ module . exports = function ( ) {
2+ var { Class, Type} = require ( "../src/runtime.js" ) ;
3+ var __ks_Array = { } ;
4+ Class . newClassMethod ( {
5+ class : Array ,
6+ name : "map" ,
7+ final : __ks_Array ,
8+ function : function ( array , iterator ) {
9+ if ( array === undefined || array === null ) {
10+ throw new Error ( "Missing parameter 'array'" ) ;
11+ }
12+ if ( ! Type . isArray ( array ) ) {
13+ throw new Error ( "Invalid type for parameter 'array'" ) ;
14+ }
15+ if ( iterator === undefined || iterator === null ) {
16+ throw new Error ( "Missing parameter 'iterator'" ) ;
17+ }
18+ if ( ! Type . isFunction ( iterator ) ) {
19+ throw new Error ( "Invalid type for parameter 'iterator'" ) ;
20+ }
21+ let results = [ ] ;
22+ for ( let index = 0 , __ks_0 = array . length , item ; index < __ks_0 ; ++ index ) {
23+ item = array [ index ] ;
24+ results . push ( iterator ( item , index ) ) ;
25+ }
26+ return results ;
27+ } ,
28+ signature : {
29+ min : 2 ,
30+ max : 2 ,
31+ parameters : [
32+ {
33+ type : "Array" ,
34+ min : 1 ,
35+ max : 1
36+ } ,
37+ {
38+ type : "Function" ,
39+ min : 1 ,
40+ max : 1
41+ }
42+ ]
43+ }
44+ } ) ;
45+ Class . newClassMethod ( {
46+ class : Array ,
47+ name : "map" ,
48+ final : __ks_Array ,
49+ function : function ( array , iterator , condition ) {
50+ if ( array === undefined || array === null ) {
51+ throw new Error ( "Missing parameter 'array'" ) ;
52+ }
53+ if ( ! Type . isArray ( array ) ) {
54+ throw new Error ( "Invalid type for parameter 'array'" ) ;
55+ }
56+ if ( iterator === undefined || iterator === null ) {
57+ throw new Error ( "Missing parameter 'iterator'" ) ;
58+ }
59+ if ( ! Type . isFunction ( iterator ) ) {
60+ throw new Error ( "Invalid type for parameter 'iterator'" ) ;
61+ }
62+ if ( condition === undefined || condition === null ) {
63+ throw new Error ( "Missing parameter 'condition'" ) ;
64+ }
65+ if ( ! Type . isFunction ( condition ) ) {
66+ throw new Error ( "Invalid type for parameter 'condition'" ) ;
67+ }
68+ let results = [ ] ;
69+ for ( let index = 0 , __ks_0 = array . length , item ; index < __ks_0 ; ++ index ) {
70+ item = array [ index ] ;
71+ if ( condition ( item , index ) ) {
72+ results . push ( iterator ( item , index ) ) ;
73+ }
74+ }
75+ return results ;
76+ } ,
77+ signature : {
78+ min : 3 ,
79+ max : 3 ,
80+ parameters : [
81+ {
82+ type : "Array" ,
83+ min : 1 ,
84+ max : 1
85+ } ,
86+ {
87+ type : "Function" ,
88+ min : 2 ,
89+ max : 2
90+ }
91+ ]
92+ }
93+ } ) ;
94+ var __ks_Function = { } ;
95+ Class . newClassMethod ( {
96+ class : Function ,
97+ name : "curry" ,
98+ final : __ks_Function ,
99+ function : function ( ) {
100+ if ( arguments . length < 2 ) {
101+ throw new Error ( "Wrong number of arguments" ) ;
102+ }
103+ let __ks_i = - 1 ;
104+ if ( Type . isFunction ( arguments [ ++ __ks_i ] ) ) {
105+ var self = arguments [ __ks_i ] ;
106+ }
107+ else throw new Error ( "Invalid type for parameter 'self'" )
108+ if ( arguments . length > 2 ) {
109+ var bind = arguments [ ++ __ks_i ] ;
110+ }
111+ else {
112+ var bind = null ;
113+ }
114+ var args = arguments [ ++ __ks_i ] ;
115+ return function ( ...supplements ) {
116+ return self . apply ( bind , args . concat ( supplements ) ) ;
117+ } ;
118+ } ,
119+ signature : {
120+ min : 2 ,
121+ max : 3 ,
122+ parameters : [
123+ {
124+ type : "Function" ,
125+ min : 1 ,
126+ max : 1
127+ } ,
128+ {
129+ type : "Any" ,
130+ min : 1 ,
131+ max : 2
132+ }
133+ ]
134+ }
135+ } ) ;
136+ Class . newClassMethod ( {
137+ class : Function ,
138+ name : "vcurry" ,
139+ final : __ks_Function ,
140+ function : function ( self , bind = null , ...args ) {
141+ if ( self === undefined || self === null ) {
142+ throw new Error ( "Missing parameter 'self'" ) ;
143+ }
144+ if ( ! Type . isFunction ( self ) ) {
145+ throw new Error ( "Invalid type for parameter 'self'" ) ;
146+ }
147+ return function ( ...supplements ) {
148+ return self . apply ( bind , args . concat ( supplements ) ) ;
149+ } ;
150+ } ,
151+ signature : {
152+ min : 1 ,
153+ max : Infinity ,
154+ parameters : [
155+ {
156+ type : "Function" ,
157+ min : 1 ,
158+ max : 1
159+ } ,
160+ {
161+ type : "Any" ,
162+ min : 0 ,
163+ max : Infinity
164+ }
165+ ]
166+ }
167+ } ) ;
168+ var __ks_Object = { } ;
169+ Class . newClassMethod ( {
170+ class : Object ,
171+ name : "append" ,
172+ final : __ks_Object ,
173+ function : function ( object , ...args ) {
174+ if ( object === undefined || object === null ) {
175+ throw new Error ( "Missing parameter 'object'" ) ;
176+ }
177+ for ( let __ks_0 = 0 , __ks_1 = args . length , arg ; __ks_0 < __ks_1 ; ++ __ks_0 ) {
178+ arg = args [ __ks_0 ] ;
179+ if ( arg ) {
180+ for ( let key in arg ) {
181+ let value = arg [ key ] ;
182+ object [ key ] = value ;
183+ }
184+ }
185+ }
186+ return object ;
187+ } ,
188+ signature : {
189+ min : 1 ,
190+ max : Infinity ,
191+ parameters : [
192+ {
193+ type : "Any" ,
194+ min : 1 ,
195+ max : Infinity
196+ }
197+ ]
198+ }
199+ } ) ;
200+ Class . newClassMethod ( {
201+ class : Object ,
202+ name : "map" ,
203+ final : __ks_Object ,
204+ function : function ( object , iterator ) {
205+ if ( object === undefined || object === null ) {
206+ throw new Error ( "Missing parameter 'object'" ) ;
207+ }
208+ if ( ! Type . isObject ( object ) ) {
209+ throw new Error ( "Invalid type for parameter 'object'" ) ;
210+ }
211+ if ( iterator === undefined || iterator === null ) {
212+ throw new Error ( "Missing parameter 'iterator'" ) ;
213+ }
214+ if ( ! Type . isFunction ( iterator ) ) {
215+ throw new Error ( "Invalid type for parameter 'iterator'" ) ;
216+ }
217+ let results = [ ] ;
218+ for ( let item in object ) {
219+ let index = object [ item ] ;
220+ results . push ( iterator ( item , index ) ) ;
221+ }
222+ return results ;
223+ } ,
224+ signature : {
225+ min : 2 ,
226+ max : 2 ,
227+ parameters : [
228+ {
229+ type : "Object" ,
230+ min : 1 ,
231+ max : 1
232+ } ,
233+ {
234+ type : "Function" ,
235+ min : 1 ,
236+ max : 1
237+ }
238+ ]
239+ }
240+ } ) ;
241+ Class . newClassMethod ( {
242+ class : Object ,
243+ name : "map" ,
244+ final : __ks_Object ,
245+ function : function ( object , iterator , condition ) {
246+ if ( object === undefined || object === null ) {
247+ throw new Error ( "Missing parameter 'object'" ) ;
248+ }
249+ if ( ! Type . isObject ( object ) ) {
250+ throw new Error ( "Invalid type for parameter 'object'" ) ;
251+ }
252+ if ( iterator === undefined || iterator === null ) {
253+ throw new Error ( "Missing parameter 'iterator'" ) ;
254+ }
255+ if ( ! Type . isFunction ( iterator ) ) {
256+ throw new Error ( "Invalid type for parameter 'iterator'" ) ;
257+ }
258+ if ( condition === undefined || condition === null ) {
259+ throw new Error ( "Missing parameter 'condition'" ) ;
260+ }
261+ if ( ! Type . isFunction ( condition ) ) {
262+ throw new Error ( "Invalid type for parameter 'condition'" ) ;
263+ }
264+ let results = [ ] ;
265+ for ( let item in object ) {
266+ let index = object [ item ] ;
267+ if ( condition ( item , index ) ) {
268+ results . push ( iterator ( item , index ) ) ;
269+ }
270+ }
271+ return results ;
272+ } ,
273+ signature : {
274+ min : 3 ,
275+ max : 3 ,
276+ parameters : [
277+ {
278+ type : "Object" ,
279+ min : 1 ,
280+ max : 1
281+ } ,
282+ {
283+ type : "Function" ,
284+ min : 2 ,
285+ max : 2
286+ }
287+ ]
288+ }
289+ } ) ;
290+ return {
291+ Array : Array ,
292+ Class : Class ,
293+ Function : Function ,
294+ Object : Object ,
295+ Type : Type ,
296+ __ks_Array : __ks_Array ,
297+ __ks_Function : __ks_Function ,
298+ __ks_Object : __ks_Object
299+ } ;
300+ }
0 commit comments