1 | "use strict";
|
2 |
|
3 | module.exports = {
|
4 | camelCase,
|
5 | CamelCase,
|
6 | isSpecial,
|
7 | contains
|
8 | };
|
9 |
|
10 |
|
11 | const NOT_FOUND = -1;
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | function contains( arr, item ) {
|
21 | return arr.indexOf( item ) !== NOT_FOUND;
|
22 | }
|
23 |
|
24 | function camelCase( name ) {
|
25 | return name.split( '.' ).map( function ( word, wordIdx ) {
|
26 | return word.split( '-' ).map( function ( piece, pieceIdx ) {
|
27 | if ( wordIdx + pieceIdx === 0 ) return piece;
|
28 | return piece.charAt( 0 ).toUpperCase() + piece.substr( 1 );
|
29 | } ).join( "" );
|
30 | } ).join( "" );
|
31 | }
|
32 |
|
33 | function CamelCase( name ) {
|
34 | var transformed = camelCase( name );
|
35 | return transformed.charAt( 0 ).toUpperCase() + transformed.substr( 1 );
|
36 | }
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | function isSpecial( obj, expectedName ) {
|
44 | var type = typeof obj;
|
45 | if ( type === 'string' || type !== 'object' || Array.isArray( obj ) ) return false;
|
46 | if ( !obj ) return false;
|
47 | var name = obj[ 0 ];
|
48 |
|
49 | if ( typeof name !== 'string' ) return false;
|
50 | if ( typeof expectedName === 'string' ) {
|
51 | return name.toLowerCase() === expectedName.toLowerCase();
|
52 | }
|
53 | return true;
|
54 | } |
\ | No newline at end of file |