Best JavaScript code snippet using cucumber-gherkin
nftypes.js
Source:nftypes.js
1var decNumRule = {2 1: "o['$name']=buf.readUInt8($pos);",3 2: "o['$name']=buf.readUInt16BE($pos);",4 3: "o['$name']=buf.readUInt8($pos)*65536+buf.readUInt16BE($pos+1);",5 4: "o['$name']=buf.readUInt32BE($pos);",6 5: "o['$name']=buf.readUInt8($pos)*4294967296+buf.readUInt32BE($pos+1);",7 6: "o['$name']=buf.readUInt16BE($pos)*4294967296+buf.readUInt32BE($pos+2);",8 8: "o['$name']=buf.readUInt32BE($pos)*4294967296+buf.readUInt32BE($pos+4);"9};10var decTimestamp = decNumRule;11var decTsMs = decTimestamp;12var decTsMcs = decTimestamp;13var decTsNs = decTimestamp;14var decIpv4Rule = {15 4: "o['$name']=(t=buf.readUInt32BE($pos),(parseInt(t/16777216)%256)+'.'+(parseInt(t/65536)%256)+'.'+(parseInt(t/256)%256)+'.'+(t%256));"16};17var decIpv6Rule = {18 16: "o['$name']=buf.toString('hex',$pos,$pos+$len);"19};20var decMacRule = {21 0: "o['$name']=buf.toString('hex',$pos,$pos+$len);"22};23var decStringRule = {24 0: 'o[\'$name\']=buf.toString(\'utf8\',$pos,$pos+$len).replace(/\\0/g,\'\');'25};26var decAsciiStringRule = {27 0: 'o[\'$name\']=buf.toString(\'ascii\',$pos,$pos+$len).replace(/\\0/g,\'\');'28};29var nfTypes = {30 1: {name: 'in_bytes', compileRule: decNumRule},31 2: {name: 'in_pkts', compileRule: decNumRule},32 3: {name: 'flows', compileRule: decNumRule},33 4: {name: 'protocol', compileRule: decNumRule},34 5: {name: 'src_tos', compileRule: decNumRule},35 6: {name: 'tcp_flags', compileRule: decNumRule},36 7: {name: 'l4_src_port', compileRule: decNumRule},37 8: {name: 'ipv4_src_addr', compileRule: decIpv4Rule},38 9: {name: 'src_mask', compileRule: decNumRule},39 10: {name: 'input_snmp', compileRule: decNumRule},40 11: {name: 'l4_dst_port', compileRule: decNumRule},41 12: {name: 'ipv4_dst_addr', compileRule: decIpv4Rule},42 13: {name: 'dst_mask', compileRule: decNumRule},43 14: {name: 'output_snmp', compileRule: decNumRule},44 15: {name: 'ipv4_next_hop', compileRule: decIpv4Rule},45 16: {name: 'src_as', compileRule: decNumRule},46 17: {name: 'dst_as', compileRule: decNumRule},47 18: {name: 'bgp_ipv4_next_hop', compileRule: decIpv4Rule},48 19: {name: 'mul_dst_pkts', compileRule: decNumRule},49 20: {name: 'mul_dst_bytes', compileRule: decNumRule},50 21: {name: 'last_switched', compileRule: decNumRule},51 22: {name: 'first_switched', compileRule: decNumRule},52 23: {name: 'out_bytes', compileRule: decNumRule},53 24: {name: 'out_pkts', compileRule: decNumRule},54 25: {name: 'min_pkt_lngth', compileRule: decNumRule},55 26: {name: 'max_pkt_lngth', compileRule: decNumRule},56 27: {name: 'ipv6_src_addr', compileRule: decIpv6Rule},57 28: {name: 'ipv6_dst_addr', compileRule: decIpv6Rule},58 29: {name: 'ipv6_src_mask', compileRule: decNumRule},59 30: {name: 'ipv6_dst_mask', compileRule: decNumRule},60 31: {name: 'ipv6_flow_label', compileRule: decNumRule},61 32: {name: 'icmp_type', compileRule: decNumRule},62 33: {name: 'mul_igmp_type', compileRule: decNumRule},63 34: {name: 'sampling_interval', compileRule: decNumRule},64 35: {name: 'sampling_algorithm', compileRule: decNumRule},65 36: {name: 'flow_active_timeout', compileRule: decNumRule},66 37: {name: 'flow_inactive_timeout', compileRule: decNumRule},67 38: {name: 'engine_type', compileRule: decNumRule},68 39: {name: 'engine_id', compileRule: decNumRule},69 40: {name: 'total_bytes_exp', compileRule: decNumRule},70 41: {name: 'total_pkts_exp', compileRule: decNumRule},71 42: {name: 'total_flows_exp', compileRule: decNumRule},72 44: {name: 'ipv4_src_prefix', compileRule: decIpv4Rule},73 45: {name: 'ipv4_dst_prefix', compileRule: decIpv4Rule},74 46: {name: 'mpls_top_label_type', compileRule: decIpv4Rule},75 47: {name: 'mpls_top_label_ip_addr', compileRule: decIpv4Rule},76 48: {name: 'flow_sampler_id', compileRule: decNumRule},77 49: {name: 'flow_sampler_mode', compileRule: decNumRule},78 50: {name: 'flow_sampler_random_interval', compileRule: decNumRule},79 52: {name: 'min_ttl', compileRule: decNumRule},80 53: {name: 'max_ttl', compileRule: decNumRule},81 54: {name: 'ipv4_ident', compileRule: decNumRule},82 55: {name: 'dst_tos', compileRule: decNumRule},83 56: {name: 'in_src_mac', compileRule: decMacRule},84 57: {name: 'out_dst_mac', compileRule: decMacRule},85 58: {name: 'src_vlan', compileRule: decNumRule},86 59: {name: 'dst_vlan', compileRule: decNumRule},87 60: {name: 'ip_protocol_version', compileRule: decNumRule},88 61: {name: 'direction', compileRule: decNumRule},89 62: {name: 'ipv6_next_hop', compileRule: decIpv6Rule},90 63: {name: 'bpg_ipv6_next_hop', compileRule: decIpv6Rule},91 64: {name: 'ipv6_option_headers', compileRule: decNumRule},92 70: {name: 'mpls_label_1', compileRule: decNumRule},93 71: {name: 'mpls_label_2', compileRule: decNumRule},94 72: {name: 'mpls_label_3', compileRule: decNumRule},95 73: {name: 'mpls_label_4', compileRule: decNumRule},96 74: {name: 'mpls_label_5', compileRule: decNumRule},97 75: {name: 'mpls_label_6', compileRule: decNumRule},98 76: {name: 'mpls_label_7', compileRule: decNumRule},99 77: {name: 'mpls_label_8', compileRule: decNumRule},100 78: {name: 'mpls_label_9', compileRule: decNumRule},101 79: {name: 'mpls_label_10', compileRule: decNumRule},102 80: {name: 'in_dst_mac', compileRule: decMacRule},103 81: {name: 'out_src_mac', compileRule: decMacRule},104 82: {name: 'if_name', compileRule: decStringRule},105 83: {name: 'if_desc', compileRule: decStringRule},106 84: {name: 'sampler_name', compileRule: decStringRule},107 85: {name: 'in_permanent_bytes', compileRule: decNumRule},108 86: {name: 'in_permanent_pkts', compileRule: decNumRule},109 87: {name: 'flagsAndSamplerId', compileRule: decNumRule}, // Deprecated110 88: {name: 'fragment_offset', compileRule: decNumRule},111 89: {name: 'fw_status', compileRule: decNumRule},112 90: {name: 'mpls_pal_rd', compileRule: decNumRule},113 91: {name: 'mpls_prefix_len', compileRule: decNumRule},114 92: {name: 'src_traffic_index', compileRule: decNumRule},115 93: {name: 'dst_traffic_index', compileRule: decNumRule},116 94: {name: 'application_descr', compileRule: decStringRule},117 95: {name: 'application_tag', compileRule: decMacRule},118 96: {name: 'application_name', compileRule: decStringRule},119 98: {name: 'postIpDiffServCodePoint', compileRule: decNumRule},120 99: {name: 'replication_factor', compileRule: decNumRule},121 100: {name: 'className', compileRule: decStringRule},122 101: {name: 'classificationEngineId', compileRule: decNumRule},123 102: {name: 'layer2packetSectionOffset', compileRule: decNumRule}, // Deprecated124 103: {name: 'layer2packetSectionSize', compileRule: decNumRule}, // Deprecated125 104: {name: 'layer2packetSectionData', compileRule: decMacRule},126 //above 127 is in ipfix127 128: {name: 'in_as', compileRule: decNumRule},128 129: {name: 'out_as', compileRule: decNumRule},129 130: {name: 'exporterIPv4Address', compileRule: decIpv4Rule},130 131: {name: 'exporterIPv6Address', compileRule: decIpv6Rule},131 132: {name: 'droppedOctetDeltaCount', compileRule: decNumRule},132 133: {name: 'droppedPacketDeltaCount', compileRule: decNumRule},133 134: {name: 'droppedOctetTotalCount', compileRule: decNumRule},134 135: {name: 'droppedPacketTotalCount', compileRule: decNumRule},135 136: {name: 'flowEndReason', compileRule: decNumRule},136 137: {name: 'commonPropertiesId', compileRule: decNumRule},137 138: {name: 'observationPointId', compileRule: decNumRule},138 139: {name: 'icmpTypeCodeIPv6', compileRule: decNumRule},139 140: {name: 'mplsTopLabelIPv6Address', compileRule: decIpv6Rule},140 141: {name: 'lineCardId', compileRule: decNumRule},141 142: {name: 'portId', compileRule: decNumRule},142 143: {name: 'meteringProcessId', compileRule: decNumRule},143 144: {name: 'exportingProcessId', compileRule: decNumRule},144 145: {name: 'templateId', compileRule: decNumRule},145 146: {name: 'wlanChannelId', compileRule: decNumRule},146 147: {name: 'wlanSSID', compileRule: decStringRule},147 148: {name: 'flowId', compileRule: decNumRule},148 149: {name: 'observationDomainId', compileRule: decNumRule},149 150: {name: 'flowStartSeconds', compileRule: decTimestamp},150 151: {name: 'flowEndSeconds', compileRule: decTimestamp},151 152: {name: 'flowStartMilliseconds', compileRule: decTsMs},152 153: {name: 'flowEndMilliseconds', compileRule: decTsMs},153 154: {name: 'flowStartMicroseconds', compileRule: decTsMcs},154 155: {name: 'flowEndMicroseconds', compileRule: decTsMcs},155 156: {name: 'flowStartNanoseconds', compileRule: decTsNs},156 157: {name: 'flowEndNanoseconds', compileRule: decTsNs},157 158: {name: 'flowStartDeltaMicroseconds', compileRule: decNumRule},158 159: {name: 'flowEndDeltaMicroseconds', compileRule: decNumRule},159 160: {name: 'systemInitTimeMilliseconds', compileRule: decTsMs},160 161: {name: 'flowDurationMilliseconds', compileRule: decNumRule},161 162: {name: 'flowDurationMicroseconds', compileRule: decNumRule},162 163: {name: 'observedFlowTotalCount', compileRule: decNumRule},163 164: {name: 'ignoredPacketTotalCount', compileRule: decNumRule},164 165: {name: 'ignoredOctetTotalCount', compileRule: decNumRule},165 166: {name: 'notSentFlowTotalCount', compileRule: decNumRule},166 167: {name: 'notSentPacketTotalCount', compileRule: decNumRule},167 168: {name: 'notSentOctetTotalCount', compileRule: decNumRule},168 169: {name: 'destinationIPv6Prefix', compileRule: decIpv6Rule},169 170: {name: 'sourceIPv6Prefix', compileRule: decIpv6Rule},170 171: {name: 'postOctetTotalCount', compileRule: decNumRule},171 172: {name: 'postPacketTotalCount', compileRule: decNumRule},172 173: {name: 'flowKeyIndicator', compileRule: decNumRule},173 174: {name: 'postMCastPacketTotalCount', compileRule: decNumRule},174 175: {name: 'postMCastOctetTotalCount', compileRule: decNumRule},175 176: {name: 'icmpTypeIPv4', compileRule: decNumRule},176 177: {name: 'icmpCodeIPv4', compileRule: decNumRule},177 178: {name: 'icmpTypeIPv6', compileRule: decNumRule},178 179: {name: 'icmpCodeIPv6', compileRule: decNumRule},179 180: {name: 'udpSourcePort', compileRule: decNumRule},180 181: {name: 'udpDestinationPort', compileRule: decNumRule},181 182: {name: 'tcpSourcePort', compileRule: decNumRule},182 183: {name: 'tcpDestinationPort', compileRule: decNumRule},183 184: {name: 'tcpSequenceNumber', compileRule: decNumRule},184 185: {name: 'tcpAcknowledgementNumber', compileRule: decNumRule},185 186: {name: 'tcpWindowSize', compileRule: decNumRule},186 187: {name: 'tcpUrgentPointer', compileRule: decNumRule},187 188: {name: 'tcpHeaderLength', compileRule: decNumRule},188 189: {name: 'ipHeaderLength', compileRule: decNumRule},189 190: {name: 'totalLengthIPv4', compileRule: decNumRule},190 191: {name: 'payloadLengthIPv6', compileRule: decNumRule},191 192: {name: 'ipTTL', compileRule: decNumRule},192 193: {name: 'nextHeaderIPv6', compileRule: decNumRule},193 194: {name: 'mplsPayloadLength', compileRule: decNumRule},194 195: {name: 'ipDiffServCodePoint', compileRule: decNumRule},195 //the following are taken from from http://www.iana.org/assignments/ipfix/ipfix.xhtml196 196: {name: 'ipPrecedence', compileRule: decNumRule},197 197: {name: 'fragmentFlags', compileRule: decNumRule},198 198: {name: 'octetDeltaSumOfSquares', compileRule: decNumRule},199 199: {name: 'octetTotalSumOfSquares', compileRule: decNumRule},200 200: {name: 'mplsTopLabelTTL', compileRule: decNumRule},201 201: {name: 'mplsLabelStackLength', compileRule: decNumRule},202 202: {name: 'mplsLabelStackDepth', compileRule: decNumRule},203 203: {name: 'mplsTopLabelExp', compileRule: decNumRule},204 204: {name: 'ipPayloadLength', compileRule: decNumRule},205 205: {name: 'udpMessageLength', compileRule: decNumRule},206 206: {name: 'isMulticast', compileRule: decNumRule},207 207: {name: 'ipv4IHL', compileRule: decNumRule},208 208: {name: 'ipv4Options', compileRule: decNumRule},209 209: {name: 'tcpOptions', compileRule: decNumRule},210 210: {name: 'paddingOctets', compileRule: decMacRule},211 211: {name: 'collectorIPv4Address', compileRule: decIpv4Rule},212 212: {name: 'collectorIPv6Address', compileRule: decIpv6Rule},213 213: {name: 'exportInterface', compileRule: decNumRule},214 214: {name: 'exportProtocolVersion', compileRule: decNumRule},215 215: {name: 'exportTransportProtocol', compileRule: decNumRule},216 216: {name: 'collectorTransportPort', compileRule: decNumRule},217 217: {name: 'exporterTransportPort', compileRule: decNumRule},218 218: {name: 'tcpSynTotalCount', compileRule: decNumRule},219 219: {name: 'tcpFinTotalCount', compileRule: decNumRule},220 220: {name: 'tcpRstTotalCount', compileRule: decNumRule},221 221: {name: 'tcpPshTotalCount', compileRule: decNumRule},222 222: {name: 'tcpAckTotalCount', compileRule: decNumRule},223 223: {name: 'tcpUrgTotalCount', compileRule: decNumRule},224 224: {name: 'ipTotalLength', compileRule: decNumRule},225 225: {name: 'postNATSourceIPv4Address', compileRule: decIpv4Rule},226 226: {name: 'postNATDestinationIPv4Address', compileRule: decIpv4Rule},227 227: {name: 'postNAPTSourceTransportPort', compileRule: decNumRule},228 228: {name: 'postNAPTDestinationTransportPort', compileRule: decNumRule},229 229: {name: 'natOriginatingAddressRealm', compileRule: decNumRule},230 230: {name: 'natEvent', compileRule: decNumRule},231 231: {name: 'initiatorOctets', compileRule: decNumRule},232 232: {name: 'responderOctets', compileRule: decNumRule},233 233: {name: 'firewallEvent', compileRule: decNumRule},234 234: {name: 'ingressVRFID', compileRule: decNumRule},235 235: {name: 'egressVRFID', compileRule: decNumRule},236 236: {name: 'VRFname', compileRule: decStringRule},237 237: {name: 'postMplsTopLabelExp', compileRule: decNumRule},238 238: {name: 'tcpWindowScale', compileRule: decNumRule},239 239: {name: 'biflow_direction', compileRule: decNumRule},240 240: {name: 'ethernetHeaderLength', compileRule: decNumRule},241 241: {name: 'ethernetPayloadLength', compileRule: decNumRule},242 242: {name: 'ethernetTotalLength', compileRule: decNumRule},243 243: {name: 'dot1qVlanId', compileRule: decNumRule},244 244: {name: 'dot1qPriority', compileRule: decNumRule},245 245: {name: 'dot1qCustomerVlanId', compileRule: decNumRule},246 246: {name: 'dot1qCustomerPriority', compileRule: decNumRule},247 247: {name: 'metroEvcId', compileRule: decStringRule},248 248: {name: 'metroEvcType', compileRule: decNumRule},249 249: {name: 'pseudoWireId', compileRule: decNumRule},250 250: {name: 'pseudoWireType', compileRule: decNumRule},251 251: {name: 'pseudoWireControlWord', compileRule: decNumRule},252 252: {name: 'ingressPhysicalInterface', compileRule: decNumRule},253 253: {name: 'egressPhysicalInterface', compileRule: decNumRule},254 254: {name: 'postDot1qVlanId', compileRule: decNumRule},255 255: {name: 'postDot1qCustomerVlanId', compileRule: decNumRule},256 256: {name: 'ethernetType', compileRule: decNumRule},257 257: {name: 'postIpPrecedence', compileRule: decNumRule},258 258: {name: 'collectionTimeMilliseconds', compileRule: decTsMs},259 259: {name: 'exportSctpStreamId', compileRule: decNumRule},260 260: {name: 'maxExportSeconds', compileRule: decTimestamp},261 261: {name: 'maxFlowEndSeconds', compileRule: decTimestamp},262 262: {name: 'messageMD5Checksum', compileRule: decMacRule},263 263: {name: 'messageScope', compileRule: decNumRule},264 264: {name: 'minExportSeconds', compileRule: decTimestamp},265 265: {name: 'minFlowStartSeconds', compileRule: decTimestamp},266 266: {name: 'opaqueOctets', compileRule: decMacRule},267 267: {name: 'sessionScope', compileRule: decNumRule},268 268: {name: 'maxFlowEndMicroseconds', compileRule: decTsMcs},269 269: {name: 'maxFlowEndMilliseconds', compileRule: decTsMs},270 270: {name: 'maxFlowEndNanoseconds', compileRule: decTsNs},271 271: {name: 'minFlowStartMicroseconds', compileRule: decTsMcs},272 272: {name: 'minFlowStartMilliseconds', compileRule: decTsMs},273 273: {name: 'minFlowStartNanoseconds', compileRule: decTsNs},274 274: {name: 'collectorCertificate', compileRule: decMacRule},275 275: {name: 'exporterCertificate', compileRule: decMacRule},276 276: {name: 'dataRecordsReliability', compileRule: decNumRule},277 277: {name: 'observationPointType', compileRule: decNumRule},278 278: {name: 'connectionCountNew', compileRule: decNumRule},279 279: {name: 'connectionSumDuration', compileRule: decNumRule},280 280: {name: 'conn_tx_id',compileRule: decNumRule},281 //282 281: {name: 'postNATSourceIPv6Address',compileRule: decIpv6Rule},283 282: {name: 'postNATDestinationIPv6Address',compileRule: decIpv6Rule},284 283: {name: 'natPoolId',compileRule: decNumRule},285 284: {name: 'natPoolName',compileRule: decStringRule},286 285: {name: 'anonymizationFlags',compileRule: decNumRule},287 286: {name: 'anonymizationTechnique',compileRule: decNumRule},288 287: {name: 'informationElementIndex',compileRule: decNumRule},289 288: {name: 'p2pTechnology',compileRule: decStringRule},290 289: {name: 'tunnelTechnology',compileRule: decStringRule},291 290: {name: 'encryptedTechnology',compileRule: decStringRule},292 // 291: {name: 'basicList',compileRule: decNumRule}, // List type, not yet supported293 // 292: {name: 'subTemplateList',compileRule: decNumRule},294 // 293: {name: 'subTemplateMultiList',compileRule: decNumRule},295 294: {name: 'bgpValidityState',compileRule: decNumRule},296 295: {name: 'IPSecSPI',compileRule: decNumRule},297 296: {name: 'greKey',compileRule: decNumRule},298 297: {name: 'natType',compileRule: decNumRule},299 298: {name: 'initiatorPackets',compileRule: decNumRule},300 299: {name: 'responderPackets',compileRule: decNumRule},301 300: {name: 'observationDomainName',compileRule: decStringRule},302 301: {name: 'selectionSequenceId',compileRule: decNumRule},303 302: {name: 'selectorId',compileRule: decNumRule},304 303: {name: 'informationElementId',compileRule: decNumRule},305 304: {name: 'selectorAlgorithm',compileRule: decNumRule},306 305: {name: 'samplingPacketInterval',compileRule: decNumRule},307 306: {name: 'samplingPacketSpace',compileRule: decNumRule},308 307: {name: 'samplingTimeInterval',compileRule: decNumRule},309 308: {name: 'samplingTimeSpace',compileRule: decNumRule},310 309: {name: 'samplingSize',compileRule: decNumRule},311 310: {name: 'samplingPopulation',compileRule: decNumRule},312 // 311: {name: 'samplingProbability',compileRule: decNumRule}, // Float type has to be introduced313 312: {name: 'dataLinkFrameSize',compileRule: decNumRule},314 313: {name: 'ipHeaderPacketSection',compileRule: decMacRule},315 314: {name: 'ipPayloadPacketSection',compileRule: decMacRule},316 315: {name: 'dataLinkFrameSection',compileRule: decMacRule},317 316: {name: 'mplsLabelStackSection',compileRule: decMacRule},318 317: {name: 'mplsPayloadPacketSection',compileRule: decMacRule},319 318: {name: 'selectorIdTotalPktsObserved',compileRule: decNumRule},320 319: {name: 'selectorIdTotalPktsSelected',compileRule: decNumRule},321 // 320: {name: 'absoluteError',compileRule: decNumRule}, // Float type322 // 321: {name: 'relativeError',compileRule: decNumRule}, // Float type323 322: {name: 'observationTimeSeconds',compileRule: decTimestamp},324 323: {name: 'observationTimeMilliseconds',compileRule: decTsMs},325 324: {name: 'observationTimeMicroseconds',compileRule: decTsMcs},326 325: {name: 'observationTimeNanoseconds',compileRule: decTsNs},327 326: {name: 'digestHashValue',compileRule: decNumRule},328 327: {name: 'hashIPPayloadOffset',compileRule: decNumRule},329 328: {name: 'hashIPPayloadSize',compileRule: decNumRule},330 329: {name: 'hashOutputRangeMin',compileRule: decNumRule},331 330: {name: 'hashOutputRangeMax',compileRule: decNumRule},332 331: {name: 'hashSelectedRangeMin',compileRule: decNumRule},333 332: {name: 'hashSelectedRangeMax',compileRule: decNumRule},334 333: {name: 'hashDigestOutput',compileRule: decNumRule},335 334: {name: 'hashInitialiserValue',compileRule: decNumRule},336 335: {name: 'selectorName',compileRule: decStringRule},337 // 336: {name: 'upperCILimit',compileRule: decNumRule}, // Float type338 // 337: {name: 'lowerCILimit',compileRule: decNumRule}, // Float339 // 338: {name: 'confidenceLevel',compileRule: decNumRule}, // Float340 339: {name: 'informationElementDataType',compileRule: decNumRule},341 340: {name: 'informationElementDescription',compileRule: decStringRule},342 341: {name: 'informationElementName',compileRule: decStringRule},343 342: {name: 'informationElementRangeBegin',compileRule: decNumRule},344 343: {name: 'informationElementRangeEnd',compileRule: decNumRule},345 344: {name: 'informationElementSemantics',compileRule: decNumRule},346 345: {name: 'informationElementUnits',compileRule: decNumRule},347 346: {name: 'privateEnterpriseNumber',compileRule: decNumRule},348 347: {name: 'virtualStationInterfaceId',compileRule: decMacRule},349 348: {name: 'virtualStationInterfaceName',compileRule: decStringRule},350 349: {name: 'virtualStationUUID',compileRule: decMacRule},351 350: {name: 'virtualStationName',compileRule: decStringRule},352 351: {name: 'layer2SegmentId',compileRule: decNumRule},353 352: {name: 'layer2OctetDeltaCount',compileRule: decNumRule},354 353: {name: 'layer2OctetTotalCount',compileRule: decNumRule},355 354: {name: 'ingressUnicastPacketTotalCount',compileRule: decNumRule},356 355: {name: 'ingressMulticastPacketTotalCount',compileRule: decNumRule},357 356: {name: 'ingressBroadcastPacketTotalCount',compileRule: decNumRule},358 357: {name: 'egressUnicastPacketTotalCount',compileRule: decNumRule},359 358: {name: 'egressBroadcastPacketTotalCount',compileRule: decNumRule},360 359: {name: 'monitoringIntervalStartMilliSeconds',compileRule: decTsMs},361 360: {name: 'monitoringIntervalEndMilliSeconds',compileRule: decTsMs},362 361: {name: 'portRangeStart',compileRule: decNumRule},363 362: {name: 'portRangeEnd',compileRule: decNumRule},364 363: {name: 'portRangeStepSize',compileRule: decNumRule},365 364: {name: 'portRangeNumPorts',compileRule: decNumRule},366 365: {name: 'staMacAddress',compileRule: decMacRule},367 366: {name: 'staIPv4Address',compileRule: decIpv4Rule},368 367: {name: 'wtpMacAddress',compileRule: decMacRule},369 368: {name: 'ingressInterfaceType',compileRule: decNumRule},370 369: {name: 'egressInterfaceType',compileRule: decNumRule},371 370: {name: 'rtpSequenceNumber',compileRule: decNumRule},372 371: {name: 'userName',compileRule: decStringRule},373 372: {name: 'applicationCategoryName',compileRule: decStringRule},374 373: {name: 'applicationSubCategoryName',compileRule: decStringRule},375 374: {name: 'applicationGroupName',compileRule: decStringRule},376 375: {name: 'originalFlowsPresent',compileRule: decNumRule},377 376: {name: 'originalFlowsInitiated',compileRule: decNumRule},378 377: {name: 'originalFlowsCompleted',compileRule: decNumRule},379 378: {name: 'distinctCountOfSourceIPAddress',compileRule: decNumRule},380 379: {name: 'distinctCountOfDestinationIPAddress',compileRule: decNumRule},381 380: {name: 'distinctCountOfSourceIPv4Address',compileRule: decNumRule},382 381: {name: 'distinctCountOfDestinationIPv4Address',compileRule: decNumRule},383 382: {name: 'distinctCountOfSourceIPv6Address',compileRule: decNumRule},384 383: {name: 'distinctCountOfDestinationIPv6Address',compileRule: decNumRule},385 384: {name: 'valueDistributionMethod',compileRule: decNumRule},386 385: {name: 'rfc3550JitterMilliseconds',compileRule: decNumRule},387 386: {name: 'rfc3550JitterMicroseconds',compileRule: decNumRule},388 387: {name: 'rfc3550JitterNanoseconds',compileRule: decNumRule},389 388: {name: 'dot1qDEI',compileRule: decNumRule},390 389: {name: 'dot1qCustomerDEI',compileRule: decNumRule},391 390: {name: 'flowSelectorAlgorithm',compileRule: decNumRule},392 391: {name: 'flowSelectedOctetDeltaCount',compileRule: decNumRule},393 392: {name: 'flowSelectedPacketDeltaCount',compileRule: decNumRule},394 393: {name: 'flowSelectedFlowDeltaCount',compileRule: decNumRule},395 394: {name: 'selectorIDTotalFlowsObserved',compileRule: decNumRule},396 395: {name: 'selectorIDTotalFlowsSelected',compileRule: decNumRule},397 396: {name: 'samplingFlowInterval',compileRule: decNumRule},398 397: {name: 'samplingFlowSpacing',compileRule: decNumRule},399 398: {name: 'flowSamplingTimeInterval',compileRule: decNumRule},400 399: {name: 'flowSamplingTimeSpacing',compileRule: decNumRule},401 400: {name: 'hashFlowDomain',compileRule: decNumRule},402 401: {name: 'transportOctetDeltaCount',compileRule: decNumRule},403 402: {name: 'transportPacketDeltaCount',compileRule: decNumRule},404 403: {name: 'originalExporterIPv4Address',compileRule: decIpv4Rule},405 404: {name: 'originalExporterIPv6Address',compileRule: decIpv6Rule},406 405: {name: 'originalObservationDomainId',compileRule: decNumRule},407 406: {name: 'intermediateProcessId',compileRule: decNumRule},408 407: {name: 'ignoredDataRecordTotalCount',compileRule: decNumRule},409 408: {name: 'dataLinkFrameType',compileRule: decNumRule},410 409: {name: 'sectionOffset',compileRule: decNumRule},411 410: {name: 'sectionExportedOctets',compileRule: decNumRule},412 411: {name: 'dot1qServiceInstanceTag',compileRule: decMacRule},413 412: {name: 'dot1qServiceInstanceId',compileRule: decNumRule},414 413: {name: 'dot1qServiceInstancePriority',compileRule: decNumRule},415 414: {name: 'dot1qCustomerSourceMacAddress',compileRule: decMacRule},416 415: {name: 'dot1qCustomerDestinationMacAddress',compileRule: decMacRule},417 417: {name: 'postLayer2OctetDeltaCount',compileRule: decNumRule},418 418: {name: 'postMCastLayer2OctetDeltaCount',compileRule: decNumRule},419 420: {name: 'postLayer2OctetTotalCount',compileRule: decNumRule},420 421: {name: 'postMCastLayer2OctetTotalCount',compileRule: decNumRule},421 422: {name: 'minimumLayer2TotalLength',compileRule: decNumRule},422 423: {name: 'maximumLayer2TotalLength',compileRule: decNumRule},423 424: {name: 'droppedLayer2OctetDeltaCount',compileRule: decNumRule},424 425: {name: 'droppedLayer2OctetTotalCount',compileRule: decNumRule},425 426: {name: 'ignoredLayer2OctetTotalCount',compileRule: decNumRule},426 427: {name: 'notSentLayer2OctetTotalCount',compileRule: decNumRule},427 428: {name: 'layer2OctetDeltaSumOfSquares',compileRule: decNumRule},428 429: {name: 'layer2OctetTotalSumOfSquares',compileRule: decNumRule},429 430: {name: 'layer2FrameDeltaCount',compileRule: decNumRule},430 431: {name: 'layer2FrameTotalCount',compileRule: decNumRule},431 432: {name: 'pseudoWireDestinationIPv4Address',compileRule: decIpv4Rule},432 433: {name: 'ignoredLayer2FrameTotalCount',compileRule: decNumRule},433 33000: {name: 'inputACL', compileRule: decMacRule},434 33001: {name: 'outputACL', compileRule: decMacRule},435 33002: {name: 'firewallExtendedEvent', compileRule: decNumRule},436 40000: {name: 'username', compileRule: decAsciiStringRule}437};438var nfScope = {439 1: { name: 'scope_system', compileRule: decMacRule },440 2: { name: 'scope_interface', compileRule: decStringRule },441 3: { name: 'scope_linecard', compileRule: decNumRule },442 4: { name: 'scope_netflow_cache', compileRule: decNumRule },443 5: { name: 'scope_template', compileRule: decStringRule }444};445module.exports = {446 nfTypes: nfTypes,447 nfScope: nfScope...
day-19.js
Source:day-19.js
...10if (rule.startsWith('"')) {11rules.set(id, new RegExp(JSON.parse(rule)))12} else {13if (topLevel) rule = '^' + rule.replaceAll('|', '$|^') + '$'14rules.set(id, new RegExp(rule.replace(/\d+/g, id => '('+compileRule(id).toString().replaceAll('/', '') + ')').replace(/\s/g, '')))15}16return rules.get(id)17}18tester = compileRule('0', true)19//tester = new RegExp('^' + compileRule('0').toString().replaceAll('/', '').replaceAll('|', '$|^') + '$')20msgs.filter(t => tester.test(t)).length21// no balancing regex in js, so brute force (five is enough yes). I have never seen a regex lag until today22;23[rawrules, msgs] =24document.body.textContent25.trim().split(/\r?\n\r?\n/).map(a => a.split(/\r?\n/))26rules = new Map()27rawrules = new Map(rawrules.map(raw => raw.split(': ')))28rawrules.set('8', '42 | 42 8')29rawrules.set('11', '42 31 | 42 11 31')30parsed = new Set()31get = id => compileRule(id).toString().replaceAll('/', '')32function compileRule (id, topLevel) {33if (rules.has(id)) return rules.get(id)34let rule = rawrules.get(id)35if (rule.startsWith('"')) {36rules.set(id, new RegExp(JSON.parse(rule)))37} else if (id === '8') {38rules.set(id, new RegExp('('+get('42') + ')+'))39} else if (id === '11') {40let str = []41// harcoding up to five /shrug42for (let i =1; i<=6; i++) str.push(43`(${get('42')}){${i}}(${get('31')}){${i}}`44)45console.log(str)46rules.set(id, 47//new RegExp('(?:'+get('42')+'{1})(?:' + get('31') + '+)')48new RegExp(str.join('|')49))50} else {51if (topLevel) rule = '^' + rule.replaceAll('|', '$|^') + '$'52rules.set(id, new RegExp(rule.replace(/\d+/g, id => '('+get(id) + ')').replace(/\s/g, '')))53}54return rules.get(id)55}56glob = id => new RegExp(get(id), 'g')57tester = compileRule('0', true)58//tester = new RegExp('^' + compileRule('0').toString().replaceAll('/', '').replaceAll('|', '$|^') + '$')59msgs.filter(t => tester.test(t)).length60//.map(t => [t.match(glob('42')).length, t.match(glob('31')).length])61// precomputing too powerful, no workie :(62;63[rawrules, msgs] =64document.body.textContent65.trim().split(/\r?\n\r?\n/).map(a => a.split(/\r?\n/))66rawrules = new Map(rawrules.map(raw => raw.split(': ')))67// rawrules.set('8', '42 | 42 8')68// rawrules.set('11', '42 31 | 42 11 31')69precomputed = new Map()70function cross (a, b) {71const res = []72for (const A of a) {...
instance-selector.js
Source:instance-selector.js
1'use strict';2exports.__esModule = true;3exports.match = match;4var _billCompiler = require('bill/compiler');5var _utils = require('./utils');6var React = require('react');7var ReactDOM = require('react-dom');8var ReactInstanceMap = require('react/lib/ReactInstanceMap');9var ReactTestUtils = require('react-addons-test-utils');10var compiler = _billCompiler.create();11compiler.registerPseudo('has', function (compiledSelector) {12 return function (root, inst) {13 var matches = findAll(inst, compiledSelector);14 return !!matches.length;15 };16});17compiler.registerPseudo('dom', function () {18 return function (root, inst) {19 return typeof root.type === 'string' && root.type.toLowerCase() === root.type;20 };21});22compiler.registerPseudo('composite', function () {23 return function (root, inst) {24 return typeof root.type === 'function';25 };26});27compiler.registerNesting('any', function (test) {28 return anyParent.bind(null, test);29});30compiler.registerNesting('>', function (test) {31 return directParent.bind(null, test);32});33function findAll(inst, test) {34 var getParent = arguments.length <= 2 || arguments[2] === undefined ? function () {35 return { parent: null };36 } : arguments[2];37 var excludeSelf = arguments.length <= 3 || arguments[3] === undefined ? true : arguments[3];38 var found = [];39 if (!inst || !inst.getPublicInstance) return found;40 var publicInst = inst.getPublicInstance(),41 element = inst._currentElement,42 parent = function parent() {43 return { parent: element, getParent: getParent };44 };45 if (!excludeSelf && test(element, inst, getParent)) found = found.concat(inst);46 if (ReactTestUtils.isDOMComponent(publicInst)) {47 (function () {48 var renderedChildren = inst._renderedChildren || {};49 Object.keys(renderedChildren).forEach(function (key) {50 found = found.concat(findAll(renderedChildren[key], test, parent, false));51 });52 })();53 } else if (_utils.isCompositeComponent(publicInst)) {54 found = found.concat(findAll(inst._renderedComponent, test, parent, false));55 }56 return found;57}58function anyParent(test, element, inst, parentNode) {59 do {60 var _parentNode = parentNode();61 var getParent = _parentNode.getParent;62 var parent = _parentNode.parent;63 element = parent;64 parentNode = getParent;65 } while (element && !test(element, test, getParent));66 return !!element;67}68function directParent(test, element, inst, parentNode) {69 element = parentNode().parent;70 return !!(element && test(element, parentNode().getParent));71}72function match(selector, inst) {73 var includeSelf = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2];74 var tree = inst.getPublicInstance ? inst : ReactInstanceMap.get(inst);75 return findAll(tree, compiler.compile(selector), undefined, !includeSelf);76}77var compile = compiler.compile;78var compileRule = compiler.compileRule;79var selector = compiler.selector;80exports.compile = compile;81exports.compileRule = compileRule;...
parsergen.js
Source:parsergen.js
...25 throw new TypeError(`Incorrect type for grammar rule ${ruleName}`);26 }27 const templateRegex = /\${(.+?)}/g;28 const compileSingle = singleRegex => singleRegex.replace(templateRegex, (match, ref) => {29 return compileRule(ref, depth + 1);30 });31 return isSingleRule ? `(?:${compileSingle(ruleText)})` : `(?:${ruleText.map(singleRegex => {32 return `(${compileSingle(singleRegex)})`;33 }).join('|')})`;34 };35 const compiledRegex = new RegExp(`^${compileRule(root, root)}$`, opts && opts.caseInsensitive ? 'i' : '');36 const pathsRelative = {[root]: 0};37 const visitedRules = new Map();38 const compileRelativePaths = (ruleName, path) => {39 const rule = grammar[ruleName];40 if (visitedRules.has(ruleName)) return visitedRules.get(ruleName);41 if (typeof rule !== 'object') return 0;42 let offset = 1;43 let subgroupLengths = 0;44 for (const group of rule.groups) {45 const [groupName, groupType] = group.split(':');46 pathsRelative[ruleName + '.' + groupName] = offset;47 offset++;48 if (groupType) {49 const numInnerGroups = compileRelativePaths(groupType, path + '.' + groupName);...
puzzle19.js
Source:puzzle19.js
...17 return obj;18 }, {});19 return {rules, messages};20}21function compileRule(rules, id = '0') {22 const {rule} = rules[id];23 const [p1, p2] = rule;24 if (p1[0] === '"a"' || p1[0] === '"b"') {25 return p1[0].charAt(1);26 }27 const rulePart1 = p1.map(rId => compileRule(rules, rId));28 if (!p2) {29 return rulePart1.join('');30 }31 const rulePart2 = p2.map(rId => compileRule(rules, rId));32 return `(?:${rulePart1.join('')}|${rulePart2.join('')})`;33}34function solve1(input) {35 const rule = new RegExp(`^${compileRule(input.rules)}$`);36 return input.messages.filter(message => rule.test(message)).length;37}38function solve2(input) {39 const rule42Str = compileRule(input.rules, '42');40 const rule31Str = compileRule(input.rules, '31');41 const rule11Str = [...new Array(5)].map((x, i) => `${rule42Str}{${i + 1}}${rule31Str}{${i + 1}}`).join('|');42 const rule = new RegExp(`^${rule42Str}+(?:${rule11Str})$`);43 return input.messages.filter(message => rule.test(message)).length;44}45function exec(inputFilename, solver, inputStr) {46 const input = inputStr || fs.readFileSync(inputFilename, 'utf-8');47 const parsedInput = parseInput(input);48 return solver(parsedInput);49}50if (!global.TEST_MODE) {51 const inputFile = 'input.txt';52 const {join} = require('path');53 const res = exec(54 join(__dirname, '__TESTS__', inputFile),...
vue-preset.js
Source:vue-preset.js
1'use strict'2const path = require('path')3const merge = require('deepmerge')4module.exports = (neutrino, options = {}) => {5 const LOADER_EXTENSIONS = /\.vue$/6 const NODE_MODULES = path.resolve(__dirname, '../node_modules')7 let config = neutrino.config8 let compileRule = config.module.rules.get('compile')9 let vueRule = config.module.rule('vue')10 let extractLoader = require.resolve('extract-loader')11 let htmlLoader = require.resolve('html-loader')12 vueRule13 .test(LOADER_EXTENSIONS)14 .use('vue')15 .loader(require.resolve('vue-loader'))16 .tap((opts = {}) => merge(opts, options))17 if (compileRule && compileRule.uses.has('babel')) {18 const babelOptions = compileRule.use('babel').get('options')19 vueRule20 .use('vue')21 .tap((opts = {}) => merge({22 // preserveWhitespace: false,23 loaders: {24 js: {25 loader: 'babel-loader',26 options: babelOptions27 }28 }29 }, opts))30 .end()31 .use('extract-html')32 .loader(extractLoader)33 .end()34 .use('html')35 .loader(htmlLoader)36 .tap((opts = {}) => merge({37 // root: neutrino.options.source38 interpolate: true,39 attrs: [':url', 'link:href', 'source:src']40 //minimize: false41 }, opts))42 .end()43 }44 config45 .resolve.extensions46 .add('.vue')47 .end().end()48 .resolveLoader.modules49 .add(NODE_MODULES)50 .end().end()...
patch_configuration.js
Source:patch_configuration.js
...20 }21 },22 handler: (req, reply) => {23 const config = req.payload;24 compileRule(req.storage, req.pre.auth0, config, req.auth.credentials.email || 'unknown')25 .then((script) => {26 req.pre.auth0.rules.getAll()27 .then(rules => {28 const payload = {29 name: 'auth0-authorization-extension',30 enabled: true,31 script32 };33 const rule = _.find(rules, { name: payload.name });34 if (!rule) {35 return req.pre.auth0.rules.create({ stage: 'login_success', ...payload });36 }37 return req.pre.auth0.rules.update({ id: rule.id }, payload);38 });...
put_update.js
Source:put_update.js
...21 };22 const name = 'auth0-authorization-extension';23 const rule = _.find(rules, { name });24 if (rule) {25 return compileRule(req.storage, req.pre.auth0, config, name)26 .then(script => req.pre.auth0.rules.update({ id: rule.id }, { name, script }));27 }28 return Promise.resolve();29 })30 .then(() => reply().code(204))31 .catch((err) => reply.error(err));32 }...
Using AI Code Generation
1var gherkin = require('gherkin');2var fs = require('fs');3var feature = fs.readFileSync('test.feature', 'utf8');4var parser = new gherkin.Parser();5var compiler = new gherkin.Compiler();6var feature = parser.parse(feature);7console.log(feature);8var compiledFeature = compiler.compile(feature);9console.log(compiledFeature);
Using AI Code Generation
1var gherkin = require('cucumber-gherkin');2var fs = require('fs');3var source = fs.readFileSync('test.feature', 'utf8');4var parser = new gherkin.Parser();5var compiler = new gherkin.Compiler();6var feature = parser.parse(source);7var compiledFeature = compiler.compile(feature);8console.log(JSON.stringify(compiledFeature, null, 2));9var gherkin = require('cucumber-gherkin');10var fs = require('fs');11var source = fs.readFileSync('test.feature', 'utf8');12var compiledFeature = gherkin.compile(source);13console.log(JSON.stringify(compiledFeature, null, 2));14var gherkin = require('cucumber-gherkin');15var fs = require('fs');16var source = fs.readFileSync('test.feature', 'utf8');17var compiledFeature = gherkin.compile(source);18console.log(JSON.stringify(compiledFeature, null, 2));19var gherkin = require('cucumber-gherkin');20var fs = require('fs');21var source = fs.readFileSync('test.feature', 'utf8');22var compiledFeature = gherkin.compile(source);23console.log(JSON.stringify(compiledFeature, null, 2));24var gherkin = require('cucumber-gherkin');25var fs = require('fs');26var source = fs.readFileSync('test.feature', 'utf8');27var compiledFeature = gherkin.compile(source);28console.log(JSON.stringify(compiledFeature, null, 2));
Using AI Code Generation
1var gherkin = require('gherkin');2var fs = require('fs');3var path = require('path');4var featurePath = path.join(__dirname, 'feature.feature');5var featureSource = fs.readFileSync(featurePath, 'utf8');6var parser = new gherkin.Parser();7var feature = parser.parse(featureSource);8var compiler = new gherkin.Compiler();9var compiled = compiler.compile(feature);10console.log(compiled);11var cucumber = require('cucumber');12var parser = new cucumber.Parser();13var feature = parser.parse(featureSource);14var compiler = new cucumber.Compiler();15var compiled = compiler.compile(feature);16console.log(compiled);17[ { type: 'Feature',18 location: { line: 1, column: 1 },19 [ { type: 'Background',20 location: { line: 3, column: 1 },21 steps: [Object] },22 { type: 'Scenario',23 location: { line: 7, column: 1 },24 steps: [Object] },25 { type: 'Scenario',26 location: { line: 11, column: 1 },27 steps: [Object] } ] } ]28{ type: 'Feature',29 location: { line: 1, column: 1 },30 [ { type: 'Scenario',31 location: { line: 7, column: 1 },32 [ { type: 'Given',33 location: { line: 8, column: 3 },34 name: 'Given' },35 { type: 'When',36 location: { line: 9, column: 3 },
Using AI Code Generation
1var gherkin = require('gherkin');2var fs = require('fs');3var path = require('path');4var feature = fs.readFileSync(path.resolve(__dirname, 'test.feature'), 'utf-8');5var parser = new gherkin.Parser();6var rule = parser.compileRule(feature);7console.log(rule);8{ type: 'Background',9 steps: [] }10{ type: 'Feature',11 [ { type: 'Scenario',12 [ { type: 'Step',13 rows: null } ] } ] }
Using AI Code Generation
1var gherkin = require('gherkin');2var parser = new gherkin.Parser();3var compiler = new gherkin.Compiler();4 Given a step";5var gherkinDocument = parser.parse(gherkinSource);6var pickles = compiler.compile(gherkinDocument);7console.log(pickles);8var gherkin = require('gherkin');9var parser = new gherkin.Parser();10var compiler = new gherkin.Compiler();11 Given a step";12var gherkinDocument = parser.parse(gherkinSource);13var pickles = compiler.compile(gherkinDocument);14console.log(pickles);15Given('I click on the button', function () {16 return driver.findElement(By.id('button')).click();17});18Then('I should see the page', function () {19 return driver.wait(until.elementLocated(By.id('page')), 10000);20});21Then('I should see the page', function () {22 return driver.wait(until.elementLocated(By.id('page')), 10000).then(function () {23 return driver.findElement(By.id('page'));24 });25});26Then('I should see the page', function () {27 return driver.wait(until.elementLocated(By.id('page')), 10000).then(function () {28 return driver.wait(un
Using AI Code Generation
1var gherkin = require('gherkin');2var parser = new gherkin.Parser();3var compiler = new gherkin.Compiler();4var gherkinSource = "Feature: Account\nScenario: Account Creation\nGiven I have a user with name \"test\" and password \"test\"";5var feature = parser.parse(gherkinSource);6var compiledFeature = compiler.compile(feature);7console.log(compiledFeature);8var gherkin = require('gherkin');9var parser = new gherkin.Parser();10var compiler = new gherkin.Compiler();11var gherkinSource = "Feature: Account\nScenario: Account Creation\nGiven I have a user with name \"test\" and password \"test\"";12var feature = parser.parse(gherkinSource);13var compiledFeature = compiler.compile(feature);14console.log(compiledFeature);15var gherkin = require('gherkin');16var parser = new gherkin.Parser();17var compiler = new gherkin.Compiler();18var gherkinSource = "Feature: Account\nScenario: Account Creation\nGiven I have a user with name \"test\" and password \"test\"";19var feature = parser.parse(gherkinSource);20var compiledFeature = compiler.compile(feature);21console.log(compiledFeature);22var gherkin = require('gherkin');23var parser = new gherkin.Parser();24var compiler = new gherkin.Compiler();25var gherkinSource = "Feature: Account\nScenario: Account Creation\nGiven I have a user with name \"test\" and password \"test\"";26var feature = parser.parse(gherkinSource);27var compiledFeature = compiler.compile(feature);28console.log(compiledFeature);29var gherkin = require('gherkin');30var parser = new gherkin.Parser();31var compiler = new gherkin.Compiler();32var gherkinSource = "Feature: Account\nScenario: Account Creation\nGiven I have a user with name \"test\" and password \"test\"";33var feature = parser.parse(gherkinSource);34var compiledFeature = compiler.compile(feature);35console.log(compiledFeature);
LambdaTest offers a detailed Cucumber testing tutorial, explaining its features, importance, best practices, and more to help you get started with running your automation testing scripts.
Here are the detailed Cucumber testing chapters to help you get started:
Get 100 minutes of automation test minutes FREE!!