@@ -83,22 +83,20 @@ const randomString = length => {
83
83
84
84
}
85
85
86
- module . exports = {
86
+ const random1011 = COEF => {
87
87
88
- digit,
89
- scalarProduct,
88
+ const
89
+ length = COEF . length - 1 ,
90
+ no = randomString ( length )
90
91
91
- randomSNILS : ( options = { } ) => {
92
+ return no + scalarProduct ( COEF . slice ( 0 , length ) , no ) % 11 % 10
92
93
93
- const
94
- length = COEF_SNILS . length - 2 ,
95
- no = randomString ( length ) ,
96
- sum = scalarProduct ( COEF_SNILS . slice ( 0 , length ) , no ) % 101 % 100
97
- result = sum < 10 ? no + '0' + sum : no + sum
94
+ }
98
95
99
- return ! options . format ? result : result . slice ( 0 , 3 ) + '-' + result . slice ( 3 , 6 ) + '-' + result . slice ( 6 , 9 ) + ' ' + result . slice ( 9 )
96
+ module . exports = {
100
97
101
- } ,
98
+ digit,
99
+ scalarProduct,
102
100
103
101
isSNILS : str => {
104
102
@@ -126,15 +124,6 @@ module.exports = {
126
124
127
125
} ,
128
126
129
- randomINN10 : ( ) => {
130
-
131
- const
132
- length = COEF_INN_10 . length - 1 ,
133
- no = randomString ( length )
134
-
135
- return no + scalarProduct ( COEF_INN_10 . slice ( 0 , length ) , no ) % 11 % 10
136
-
137
- } ,
138
127
139
128
isINN12 : str => {
140
129
@@ -156,16 +145,6 @@ module.exports = {
156
145
157
146
} ,
158
147
159
- randomOGRN13 : ( ) => {
160
-
161
- const
162
- length = COEF_OGRN_13 . length - 1 ,
163
- no = randomString ( length )
164
-
165
- return no + scalarProduct ( COEF_OGRN_13 . slice ( 0 , length ) , no ) % 11 % 10
166
-
167
- } ,
168
-
169
148
isOGRN13 : str => {
170
149
171
150
const tobe = scalarProduct ( COEF_OGRN_13 , str ) % 11 % 10 , asis = digit ( str , 12 )
@@ -174,15 +153,6 @@ module.exports = {
174
153
175
154
} ,
176
155
177
- randomOGRN15 : ( ) => {
178
-
179
- const
180
- length = COEF_OGRN_15 . length - 1 ,
181
- no = randomString ( length )
182
-
183
- return no + scalarProduct ( COEF_OGRN_15 . slice ( 0 , length ) , no ) % 11 % 10
184
-
185
- } ,
186
156
187
157
isOGRN15 : str => {
188
158
@@ -204,4 +174,20 @@ module.exports = {
204
174
205
175
} ,
206
176
177
+ randomINN10 : ( ) => random1011 ( COEF_INN_10 ) ,
178
+ randomOGRN13 : ( ) => random1011 ( COEF_OGRN_13 ) ,
179
+ randomOGRN15 : ( ) => random1011 ( COEF_OGRN_15 ) ,
180
+
181
+ randomSNILS : ( options = { } ) => {
182
+
183
+ const
184
+ length = COEF_SNILS . length - 2 ,
185
+ no = randomString ( length ) ,
186
+ sum = scalarProduct ( COEF_SNILS . slice ( 0 , length ) , no ) % 101 % 100
187
+ result = sum < 10 ? no + '0' + sum : no + sum
188
+
189
+ return ! options . format ? result : result . slice ( 0 , 3 ) + '-' + result . slice ( 3 , 6 ) + '-' + result . slice ( 6 , 9 ) + ' ' + result . slice ( 9 )
190
+
191
+ } ,
192
+
207
193
}
0 commit comments