Input: Create an instance of Axios [CODESPLIT] function createInstance ( defaultConfig ) { var context = new Axios ( defaultConfig ) ; var instance = bind ( Axios . prototype . request , context ) ; // Copy axios.prototype to instance utils . extend ( instance , Axios . prototype , context ) ; // Copy context to instance utils . extend ( instance , context ) ; return instance ; }


Input: A CancelToken is an object that can be used to request cancellation of an operation . [CODESPLIT] function CancelToken ( executor ) { if ( typeof executor !== 'function' ) { throw new TypeError ( 'executor must be a function.' ) ; } var resolvePromise ; this . promise = new Promise ( function promiseExecutor ( resolve ) { resolvePromise = resolve ; } ) ; var token = this ; executor ( function cancel ( message ) { if ( token . reason ) { // Cancellation has already been requested return ; } token . reason = new Cancel ( message ) ; resolvePromise ( token . reason ) ; } ) ; }


Input: Determine if a value is a view on an ArrayBuffer [CODESPLIT] function isArrayBufferView ( val ) { var result ; if ( ( typeof ArrayBuffer !== 'undefined' ) && ( ArrayBuffer . isView ) ) { result = ArrayBuffer . isView ( val ) ; } else { result = ( val ) && ( val . buffer ) && ( val . buffer instanceof ArrayBuffer ) ; } return result ; }


Input: Determine if we re running in a standard browser environment [CODESPLIT] function isStandardBrowserEnv ( ) { if ( typeof navigator !== 'undefined' && ( navigator . product === 'ReactNative' || navigator . product === 'NativeScript' || navigator . product === 'NS' ) ) { return false ; } return ( typeof window !== 'undefined' && typeof document !== 'undefined' ) ; }


Input: Iterate over an Array or an Object invoking a function for each item . [CODESPLIT] function forEach ( obj , fn ) { // Don't bother if no value provided if ( obj === null || typeof obj === 'undefined' ) { return ; } // Force an array if not already something iterable if ( typeof obj !== 'object' ) { /*eslint no-param-reassign:0*/ obj = [ obj ] ; } if ( isArray ( obj ) ) { // Iterate over array values for ( var i = 0 , l = obj . length ; i < l ; i ++ ) { fn . call ( null , obj [ i ] , i , obj ) ; } } else { // Iterate over object keys for ( var key in obj ) { if ( Object . prototype . hasOwnProperty . call ( obj , key ) ) { fn . call ( null , obj [ key ] , key , obj ) ; } } } }


Input: Extends object a by mutably adding to it the properties of object b . [CODESPLIT] function extend ( a , b , thisArg ) { forEach ( b , function assignValue ( val , key ) { if ( thisArg && typeof val === 'function' ) { a [ key ] = bind ( val , thisArg ) ; } else { a [ key ] = val ; } } ) ; return a ; }


Input: Define a function that fetches the results of an operation ( query / mutation / etc ) and returns its results as a Promise : [CODESPLIT] function fetchQuery ( operation , variables , cacheConfig , uploadables ) { // Because we implement the graphql server, the client must to point to the same host const relayServer = process . browser ? '' : process . env . RELAY_SERVER return fetch ( ` ${ relayServer } ` , { method : 'POST' , headers : { Accept : 'application/json' , 'Content-Type' : 'application/json' } , // Add authentication and other headers here body : JSON . stringify ( { query : operation . text , // GraphQL text from input variables } ) } ) . then ( response => response . json ( ) ) }


Input: konstructor : The redis client constructor method . All redis methods must be promises args : The arguments to pass to the constructor buildNew : is it new konstructor () or just konstructor () ? [CODESPLIT] function retryStrategy ( times ) { if ( times === 1 ) { const error = 'Unable to connect to Redis - please check your Redis config!' if ( process . env . NODE_ENV === 'test' ) { console . error ( error ) } else { api . log ( error , 'error' ) } return 5000 } return Math . min ( times * 50 , maxBackoff ) }


Input: This function writes a minimal package . json file for a compiled package . It defines name main author and license . It also defines types . n . b . types intended for development usage only . [CODESPLIT] function writePackageManifest ( packageName ) { const packagePath = require . resolve ( packageName + '/package.json' ) let { name , main , author , license , types , typings } = require ( packagePath ) if ( ! main ) { main = 'index.js' } let typesFile = types || typings if ( typesFile ) { typesFile = require . resolve ( join ( packageName , typesFile ) ) } const compiledPackagePath = join ( __dirname , ` ${ packageName } ` ) const potentialLicensePath = join ( dirname ( packagePath ) , './LICENSE' ) if ( existsSync ( potentialLicensePath ) ) { this . _ . files . push ( { dir : compiledPackagePath , base : 'LICENSE' , data : readFileSync ( potentialLicensePath , 'utf8' ) } ) } this . _ . files . push ( { dir : compiledPackagePath , base : 'package.json' , data : JSON . stringify ( Object . assign ( { } , { name , main : ` ${ basename ( main , '.' + extname ( main ) ) } ` } , author ? { author } : undefined , license ? { license } : undefined , typesFile ? { types : relative ( compiledPackagePath , typesFile ) } : undefined ) ) + '\n' } ) }


Input: smaller version of https : // gist . github . com / igrigorik / a02f2359f3bc50ca7a9c [CODESPLIT] function supportsPreload ( list ) { if ( ! list || ! list . supports ) { return false } try { return list . supports ( 'preload' ) } catch ( e ) { return false } }


Input: Based on https : // github . com / webpack / webpack / blob / master / lib / DynamicEntryPlugin . js#L29 - L37 [CODESPLIT] function addEntry ( compilation , context , name , entry ) { return new Promise ( ( resolve , reject ) => { const dep = DynamicEntryPlugin . createDependency ( entry , name ) compilation . addEntry ( context , dep , name , ( err ) => { if ( err ) return reject ( err ) resolve ( ) } ) } ) }


Input: Compilation with warnings ( e . g . ESLint ) . [CODESPLIT] function handleWarnings ( warnings ) { clearOutdatedErrors ( ) // Print warnings to the console. const formatted = formatWebpackMessages ( { warnings : warnings , errors : [ ] } ) if ( typeof console !== 'undefined' && typeof console . warn === 'function' ) { for ( let i = 0 ; i < formatted . warnings . length ; i ++ ) { if ( i === 5 ) { console . warn ( 'There were more warnings in other files.\n' + 'You can find a complete log in the terminal.' ) break } console . warn ( stripAnsi ( formatted . warnings [ i ] ) ) } } }


Input: Compilation with errors ( e . g . syntax error or missing modules ) . [CODESPLIT] function handleErrors ( errors ) { clearOutdatedErrors ( ) isFirstCompilation = false hasCompileErrors = true // "Massage" webpack messages. var formatted = formatWebpackMessages ( { errors : errors , warnings : [ ] } ) // Only show the first error. ErrorOverlay . reportBuildError ( formatted . errors [ 0 ] ) // Also log them to the console. if ( typeof console !== 'undefined' && typeof console . error === 'function' ) { for ( var i = 0 ; i < formatted . errors . length ; i ++ ) { console . error ( stripAnsi ( formatted . errors [ i ] ) ) } } }


Input: Handle messages from the server . [CODESPLIT] function processMessage ( e ) { const obj = JSON . parse ( e . data ) switch ( obj . action ) { case 'building' : { console . log ( '[HMR] bundle ' + ( obj . name ? "'" + obj . name + "' " : '' ) + 'rebuilding' ) break } case 'built' : case 'sync' : { clearOutdatedErrors ( ) if ( obj . hash ) { handleAvailableHash ( obj . hash ) } if ( obj . warnings . length > 0 ) { handleWarnings ( obj . warnings ) } if ( obj . errors . length > 0 ) { // When there is a compilation error coming from SSR we have to reload the page on next successful compile if ( obj . action === 'sync' ) { hadRuntimeError = true } handleErrors ( obj . errors ) break } handleSuccess ( ) break } default : { if ( customHmrEventHandler ) { customHmrEventHandler ( obj ) break } break } } }


Input: Attempt to update code on the fly fall back to a hard reload . [CODESPLIT] async function tryApplyUpdates ( onHotUpdateSuccess ) { if ( ! module . hot ) { // HotModuleReplacementPlugin is not in Webpack configuration. console . error ( 'HotModuleReplacementPlugin is not in Webpack configuration.' ) // window.location.reload(); return } if ( ! isUpdateAvailable ( ) || ! canApplyUpdates ( ) ) { return } function handleApplyUpdates ( err , updatedModules ) { if ( err || hadRuntimeError ) { if ( err ) { console . warn ( 'Error while applying updates, reloading page' , err ) } if ( hadRuntimeError ) { console . warn ( 'Had runtime error previously, reloading page' ) } window . location . reload ( ) return } if ( typeof onHotUpdateSuccess === 'function' ) { // Maybe we want to do something. onHotUpdateSuccess ( ) } if ( isUpdateAvailable ( ) ) { // While we were updating, there was a new update! Do it again. tryApplyUpdates ( ) } } // https://webpack.github.io/docs/hot-module-replacement.html#check try { const updatedModules = await module . hot . check ( /* autoApply */ { ignoreUnaccepted : true } ) if ( updatedModules ) { handleApplyUpdates ( null , updatedModules ) } } catch ( err ) { handleApplyUpdates ( err , null ) } }


Input: This function reads code updates on the fly and hard reloads the page when it has changed . [CODESPLIT] async function tryApplyUpdates ( ) { if ( ! isUpdateAvailable ( ) || ! canApplyUpdates ( ) ) { return } try { const res = await fetch ( ` ${ hotUpdatePath } ${ curHash } ` ) const data = await res . json ( ) const curPage = page === '/' ? 'index' : page const pageUpdated = Object . keys ( data . c ) . some ( mod => { return ( mod . indexOf ( ` ${ curPage . substr ( 0 , 1 ) === '/' ? curPage : ` ${ curPage } ` } ` ) !== - 1 || mod . indexOf ( ` ${ curPage . substr ( 0 , 1 ) === '/' ? curPage : ` ${ curPage } ` } ` . replace ( / \/ / g , '\\' ) ) !== - 1 ) } ) if ( pageUpdated ) { document . location . reload ( true ) } else { curHash = mostRecentHash } } catch ( err ) { console . error ( 'Error occurred checking for update' , err ) document . location . reload ( true ) } }


Input: Cleans up webpack error messages . eslint - disable - next - line no - unused - vars [CODESPLIT] function formatMessage ( message , isError ) { let lines = message . split ( '\n' ) // Strip Webpack-added headers off errors/warnings // https://github.com/webpack/webpack/blob/master/lib/ModuleError.js lines = lines . filter ( line => ! / Module [A-z ]+\(from / . test ( line ) ) // Transform parsing error into syntax error // TODO: move this to our ESLint formatter? lines = lines . map ( line => { const parsingError = / Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$ / . exec ( line ) if ( ! parsingError ) { return line } const [ , errorLine , errorColumn , errorMessage ] = parsingError return ` ${ friendlySyntaxErrorLabel } ${ errorMessage } ${ errorLine } ${ errorColumn } ` } ) message = lines . join ( '\n' ) // Smoosh syntax errors (commonly found in CSS) message = message . replace ( / SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n / g , ` ${ friendlySyntaxErrorLabel } \n ` ) // Remove columns from ESLint formatter output (we added these for more // accurate syntax errors) message = message . replace ( / Line (\d+):\d+: / g , 'Line $1:' ) // Clean up export errors message = message . replace ( / ^.*export '(.+?)' was not found in '(.+?)'.*$ / gm , ` ` ) message = message . replace ( / ^.*export 'default' \(imported as '(.+?)'\) was not found in '(.+?)'.*$ / gm , ` ` ) message = message . replace ( / ^.*export '(.+?)' \(imported as '(.+?)'\) was not found in '(.+?)'.*$ / gm , ` ` ) lines = message . split ( '\n' ) // Remove leading newline if ( lines . length > 2 && lines [ 1 ] . trim ( ) === '' ) { lines . splice ( 1 , 1 ) } // Clean up file name lines [ 0 ] = lines [ 0 ] . replace ( / ^(.*) \d+:\d+-\d+$ / , '$1' ) // Cleans up verbose "module not found" messages for files and packages. if ( lines [ 1 ] && lines [ 1 ] . indexOf ( 'Module not found: ' ) === 0 ) { lines = [ lines [ 0 ] , lines [ 1 ] . replace ( 'Error: ' , '' ) . replace ( 'Module not found: Cannot find file:' , 'Cannot find file:' ) ] } message = lines . join ( '\n' ) // Internal stacks are generally useless so we strip them... with the // exception of stacks containing `webpack:` because they're normally // from user code generated by Webpack. For more information see // https://github.com/facebook/create-react-app/pull/1050 message = message . replace ( / ^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$) / gm , '' ) // at ... ...:x:y message = message . replace ( / ^\s*at\s<anonymous>(\n|$) / gm , '' ) // at <anonymous> lines = message . split ( '\n' ) // Remove duplicated newlines lines = lines . filter ( ( line , index , arr ) => index === 0 || line . trim ( ) !== '' || line . trim ( ) !== arr [ index - 1 ] . trim ( ) ) // Reassemble the message message = lines . join ( '\n' ) return message . trim ( ) }


Input: / * eslint no - unused - vars : off [CODESPLIT] function slideNext ( speed = this . params . speed , runCallbacks = true , internal ) { const swiper = this ; const { params , animating } = swiper ; if ( params . loop ) { if ( animating ) return false ; swiper . loopFix ( ) ; // eslint-disable-next-line swiper . _clientLeft = swiper . $wrapperEl [ 0 ] . clientLeft ; return swiper . slideTo ( swiper . activeIndex + params . slidesPerGroup , speed , runCallbacks , internal ) ; } return swiper . slideTo ( swiper . activeIndex + params . slidesPerGroup , speed , runCallbacks , internal ) ; }


Input: / * eslint no - unused - vars : off [CODESPLIT] function slidePrev ( speed = this . params . speed , runCallbacks = true , internal ) { const swiper = this ; const { params , animating , snapGrid , slidesGrid , rtlTranslate , } = swiper ; if ( params . loop ) { if ( animating ) return false ; swiper . loopFix ( ) ; // eslint-disable-next-line swiper . _clientLeft = swiper . $wrapperEl [ 0 ] . clientLeft ; } const translate = rtlTranslate ? swiper . translate : - swiper . translate ; function normalize ( val ) { if ( val < 0 ) return - Math . floor ( Math . abs ( val ) ) ; return Math . floor ( val ) ; } const normalizedTranslate = normalize ( translate ) ; const normalizedSnapGrid = snapGrid . map ( val => normalize ( val ) ) ; const normalizedSlidesGrid = slidesGrid . map ( val => normalize ( val ) ) ; const currentSnap = snapGrid [ normalizedSnapGrid . indexOf ( normalizedTranslate ) ] ; const prevSnap = snapGrid [ normalizedSnapGrid . indexOf ( normalizedTranslate ) - 1 ] ; let prevIndex ; if ( typeof prevSnap !== 'undefined' ) { prevIndex = slidesGrid . indexOf ( prevSnap ) ; if ( prevIndex < 0 ) prevIndex = swiper . activeIndex - 1 ; } return swiper . slideTo ( prevIndex , speed , runCallbacks , internal ) ; }


Input: Original Name encode and decode logic is in github . com / eosio / eos native . hpp Encode a name ( a base32 string ) to a number . [CODESPLIT] function encodeName ( name ) { var littleEndian = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : true ; if ( typeof name !== "string" ) throw new TypeError ( "name parameter is a required string" ) ; if ( name . length > 13 ) throw new TypeError ( "A name can be up to 13 characters long" ) ; var bitstr = "" ; for ( var i = 0 ; i <= 12 ; i ++ ) { // process all 64 bits (even if name is short) var c = i < name . length ? charidx ( name [ i ] ) : 0 ; var bitlen = i < 12 ? 5 : 4 ; var bits = Number ( c ) . toString ( 2 ) ; if ( bits . length > bitlen ) { throw new TypeError ( "Invalid name " + name ) ; } bits = "0" . repeat ( bitlen - bits . length ) + bits ; bitstr += bits ; } var value = Long . fromString ( bitstr , true , 2 ) ; // convert to LITTLE_ENDIAN var leHex = "" ; var bytes = littleEndian ? value . toBytesLE ( ) : value . toBytesBE ( ) ; var _iteratorNormalCompletion = true ; var _didIteratorError = false ; var _iteratorError = undefined ; try { for ( var _iterator = ( 0 , _getIterator3 . default ) ( bytes ) , _step ; ! ( _iteratorNormalCompletion = ( _step = _iterator . next ( ) ) . done ) ; _iteratorNormalCompletion = true ) { var b = _step . value ; var n = Number ( b ) . toString ( 16 ) ; leHex += ( n . length === 1 ? "0" : "" ) + n ; } } catch ( err ) { _didIteratorError = true ; _iteratorError = err ; } finally { try { if ( ! _iteratorNormalCompletion && _iterator . return ) { _iterator . return ( ) ; } } finally { if ( _didIteratorError ) { throw _iteratorError ; } } } var ulName = Long . fromString ( leHex , true , 16 ) . toString ( ) ; // console.log('encodeName', name, value.toString(), ulName.toString(), JSON.stringify(bitstr.split(/(.....)/).slice(1))) return ulName . toString ( ) ; }


Input: Normalize and validate decimal string ( potentially large values ) . Should avoid internationalization issues if possible but will be safe and throw an error for an invalid number . [CODESPLIT] function UDecimalString ( value ) { assert ( value != null , "value is required" ) ; value = value === "object" && value . toString ? value . toString ( ) : String ( value ) ; if ( value [ 0 ] === "." ) { value = '0' + value ; } var part = value . split ( "." ) ; assert ( part . length <= 2 , 'invalid decimal ' + value ) ; assert ( / ^\d+(,?\d)*\d*$ / . test ( part [ 0 ] ) , 'invalid decimal ' + value ) ; if ( part . length === 2 ) { assert ( / ^\d*$ / . test ( part [ 1 ] ) , 'invalid decimal ' + value ) ; part [ 1 ] = part [ 1 ] . replace ( / 0+$ / , "" ) ; // remove suffixing zeros if ( part [ 1 ] === "" ) { part . pop ( ) ; } } part [ 0 ] = part [ 0 ] . replace ( / ^0* / , "" ) ; // remove leading zeros if ( part [ 0 ] === "" ) { part [ 0 ] = "0" ; } return part . join ( "." ) ; }


Input: Ensure a fixed number of decimal places . Safe for large numbers . [CODESPLIT] function UDecimalPad ( num , precision ) { var value = UDecimalString ( num ) ; assert . equal ( "number" , typeof precision === 'undefined' ? 'undefined' : ( 0 , _typeof3 . default ) ( precision ) , "precision" ) ; var part = value . split ( "." ) ; if ( precision === 0 && part . length === 1 ) { return part [ 0 ] ; } if ( part . length === 1 ) { return part [ 0 ] + '.' + "0" . repeat ( precision ) ; } else { var pad = precision - part [ 1 ] . length ; assert ( pad >= 0 , 'decimal \'' + value + '\' exceeds precision ' + precision ) ; return part [ 0 ] + '.' + part [ 1 ] + "0" . repeat ( pad ) ; } }


Input: Put the decimal place back in its position and return the normalized number string ( with any unnecessary zeros or an unnecessary decimal removed ) . [CODESPLIT] function UDecimalUnimply ( value , precision ) { assert ( value != null , "value is required" ) ; value = value === "object" && value . toString ? value . toString ( ) : String ( value ) ; assert ( / ^\d+$ / . test ( value ) , 'invalid whole number ' + value ) ; // Ensure minimum length var pad = precision - value . length ; if ( pad > 0 ) { value = '' + "0" . repeat ( pad ) + value ; } var dotIdx = value . length - precision ; value = value . slice ( 0 , dotIdx ) + '.' + value . slice ( dotIdx ) ; return UDecimalString ( value ) ; // Normalize }


Input: @arg { string } assetSymbol - 4 SYM @arg { number } [ precision = null ] - expected precision or mismatch AssertionError [CODESPLIT] function parseAssetSymbol ( assetSymbol ) { var precision = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : null ; assert . equal ( typeof assetSymbol === 'undefined' ? 'undefined' : ( 0 , _typeof3 . default ) ( assetSymbol ) , "string" , "Asset symbol should be string" ) ; if ( assetSymbol . indexOf ( "," ) === - 1 ) { assetSymbol = ',' + assetSymbol ; // null precision } var v = assetSymbol . split ( "," ) ; assert ( v . length === 2 , 'Asset symbol "' + assetSymbol + '" may have a precision like this: 4,SYM' ) ; var symbolPrecision = v [ 0 ] == "" ? null : parseInt ( v [ 0 ] ) ; var symbol = v [ 1 ] ; if ( precision != null ) { assert . equal ( precision , symbolPrecision , "Asset symbol precision mismatch" ) ; } else { precision = symbolPrecision ; } if ( precision != null ) { assert . equal ( typeof precision === 'undefined' ? 'undefined' : ( 0 , _typeof3 . default ) ( precision ) , "number" , "precision" ) ; assert ( precision > - 1 , "precision must be positive" ) ; } if ( ! / ^[0-9]+$ / . test ( symbol ) ) { if ( / ^S#[0-9]+$ / . test ( symbol ) ) { symbol = symbol . replace ( "S#" , "" ) ; } else { throw new Error ( 'Asset symbol should looks like \'S#{num}\', but got ' + symbol + '.' ) ; } } assert ( precision <= 18 , "Precision should be 18 characters or less" ) ; assert ( symbol . length <= 7 , "Asset symbol is 7 characters or less" ) ; return { precision : precision , symbol : symbol } ; }


Input: / * Encode EVT Address in address . cpp [CODESPLIT] function encodeAddress ( str ) { /* Check avalibility of evt_address */ if ( typeof str !== "string" || str . length !== 53 || ! str . startsWith ( "EVT" ) ) throw new Error ( "EVTAddress should be a string with length 53 starts with EVT." ) ; str = str . substr ( 3 ) ; if ( str === "0" . repeat ( 50 ) ) return Buffer . from ( [ 0 , 0 ] ) ; // 0000 else if ( str [ 0 ] === "0" ) return encodeGeneratedAddressToBin ( "EVT" + str ) ; // generated address var buf = Buffer . concat ( [ Buffer . from ( [ 1 , 0 ] ) , new Buffer ( base58 . decode ( str ) ) ] ) ; // normal //console.log(buf) return buf . slice ( 0 , buf . length - 4 ) ; }


Input: / * Decode EVT Address in address . cpp [CODESPLIT] function decodeAddress ( bytes ) { if ( bytes . length === 2 && bytes . equals ( Buffer . from ( [ 0 , 0 ] ) ) ) return "EVT" + "0" . repeat ( 50 ) ; // 0000 else if ( bytes . slice ( 0 , 2 ) . equals ( Buffer . from ( [ 2 , 0 ] ) ) ) return decodeGeneratedAddressFromBin ( bytes ) ; // generated address return "EVT" + KeyUtils . checkEncode ( bytes . slice ( 2 ) ) ; }


Input: create a buffer representing a segment . Different typeKey has different data type this is the detail : 0 - 20 1 - byte unsigned integer 21 - 40 2 - byte unsigned integer ( BE ) 41 - 90 4 - byte unsigned integer ( BE ) 91 - 155 string 156 - 165 uuid 166 - 180 byte string > 180 remained [CODESPLIT] function createSegment ( typeKey , value ) { // 1-byte unsigned integer if ( typeKey <= 20 ) { return ( new Buffer ( [ typeKey , value ] ) ) ; } // 2-byte unsigned integer if ( typeKey <= 40 ) { let content = new Buffer ( 3 ) ; content . writeUInt8 ( typeKey , 0 ) ; content . writeUInt16BE ( value , 1 ) ; return ( content ) ; } // 4-byte unsigned integer else if ( typeKey <= 90 ) { let content = new Buffer ( 5 ) ; content . writeUInt8 ( typeKey , 0 ) ; content . writeUInt32BE ( value , 1 ) ; return ( content ) ; } // string else if ( typeKey <= 155 ) { let content = Buffer . from ( value ) ; let header = new Buffer ( [ typeKey , content . length ] ) ; return ( Buffer . concat ( [ header , content ] ) ) ; } // uuid else if ( typeKey <= 165 ) { return ( Buffer . concat ( [ new Buffer ( [ typeKey ] ) , value ] ) ) ; } // byte string else if ( typeKey <= 180 ) { let content = value ; let header = new Buffer ( [ typeKey , content . length ] ) ; return ( Buffer . concat ( [ header , content ] ) ) ; } else { throw new Error ( "typeKey not supported" ) ; } }


Input: Parse a segment and convert it into json . [CODESPLIT] function parseSegment ( buffer , offset ) { let typeKey = buffer [ offset ] ; if ( typeKey <= 20 ) { if ( buffer [ offset + 1 ] == undefined ) throw new Error ( "ParseError: No value for uint8" ) ; return { typeKey : typeKey , value : buffer [ offset + 1 ] , bufferLength : 2 } ; } if ( typeKey <= 40 ) { if ( buffer [ offset + 2 ] == undefined ) throw new Error ( "ParseError: Incomplete value for uint16" ) ; return { typeKey : typeKey , value : buffer . readUInt16BE ( offset + 1 ) , bufferLength : 3 } ; } else if ( typeKey <= 90 ) { if ( buffer [ offset + 4 ] == undefined ) throw new Error ( "ParseError: Incomplete value for uint32" ) ; return { typeKey : typeKey , value : buffer . readUInt32BE ( offset + 1 ) , bufferLength : 5 } ; } else if ( typeKey <= 155 ) { if ( buffer [ offset + 1 ] == undefined ) throw new Error ( "ParseError: Incomplete length value for string" ) ; let len = buffer . readUInt8 ( offset + 1 ) ; if ( buffer [ offset + 1 + len ] == undefined ) throw new Error ( "ParseError: Incomplete value for string" ) ; let value = buffer . toString ( "utf8" , offset + 2 , offset + 2 + len ) ; return { typeKey : typeKey , value : value , bufferLength : 2 + len } ; } else if ( typeKey <= 165 ) { if ( buffer [ offset + 16 ] == undefined ) throw new Error ( "ParseError: Incomplete value for uuid" ) ; let len = 16 ; let value = new Buffer ( len ) ; buffer . copy ( value , 0 , offset + 1 , offset + 1 + len ) ; return { typeKey : typeKey , value : value , bufferLength : 1 + len } ; } else if ( typeKey <= 180 ) { if ( buffer [ offset + 1 ] == undefined ) throw new Error ( "ParseError: Incomplete length value for byte string" ) ; let len = buffer . readUInt8 ( offset + 1 ) ; if ( buffer [ offset + len + 1 ] == undefined ) throw new Error ( "ParseError: Incomplete value for byte string" ) ; let value = new Buffer ( len ) ; buffer . copy ( value , 0 , offset + 2 , offset + 2 + len ) ; return { typeKey : typeKey , value : value , bufferLength : 2 + len } ; } else { throw new Error ( "typeKey not supported" ) ; } }


Input: Parse a buffer to a array of segments [CODESPLIT] function parseSegments ( buffer ) { if ( buffer . length == 0 ) throw new Error ( "bad segments stream" ) ; let pointer = 0 ; let segments = [ ] ; while ( pointer < buffer . length ) { let seg = parseSegment ( buffer , pointer ) ; segments . push ( seg ) ; pointer += seg . bufferLength ; delete seg . bufferLength ; } if ( pointer != buffer . length ) { throw new Error ( "Bad / incomplete segments" ) ; } return segments ; }


Input: Parse a everiToken s QRCode Text [CODESPLIT] function parseQRCode ( text , options ) { if ( text . length < 3 || text . length > 2000 ) throw new Error ( "Invalid length of EvtLink" ) ; let textSplited = text . split ( "_" ) ; if ( textSplited . length > 2 ) return null ; let rawText ; if ( textSplited [ 0 ] . startsWith ( qrPrefix ) ) { rawText = textSplited [ 0 ] . substr ( qrPrefix . length ) ; } else { rawText = textSplited [ 0 ] ; } // decode segments base42 let segmentsBytes = EvtLink . dec2b ( rawText ) ; if ( segmentsBytes . length < 2 ) throw new Error ( "no flag in segment" ) ; let flag = segmentsBytes . readInt16BE ( 0 ) ; if ( ( flag & 1 ) == 0 ) { // check version of EvtLink throw new Error ( "The EvtLink is invalid or its version is newer than version 1 and is not supported by evtjs yet" ) ; } let segmentsBytesRaw = new Buffer ( segmentsBytes . length - 2 ) ; segmentsBytes . copy ( segmentsBytesRaw , 0 , 2 , segmentsBytes . length ) ; let publicKeys = [ ] ; let signatures = [ ] ; if ( textSplited [ 1 ] ) { let buf = EvtLink . dec2b ( textSplited [ 1 ] ) ; let i = 0 ; if ( buf . length % 65 !== 0 ) { throw new Error ( "length of signature is invalid" ) ; } while ( i * 65 < buf . length ) { let current = new Buffer ( 65 ) ; buf . copy ( current , 0 , i * 65 , i * 65 + 65 ) ; let signature = ecc . Signature . fromBuffer ( current ) ; signatures . push ( signature . toString ( ) ) ; if ( ! options || options . recoverPublicKeys ) { publicKeys . push ( signature . recover ( segmentsBytes ) . toString ( ) ) ; } ++ i ; } } return { flag , segments : parseSegments ( segmentsBytesRaw ) , publicKeys , signatures } ; }


Input: Calculate the value of keyProvider [CODESPLIT] async function __calcKeyProvider ( keyProvider ) { if ( ! keyProvider ) { return [ ] ; } // if keyProvider is function if ( keyProvider . apply && keyProvider . call ) { keyProvider = keyProvider ( ) ; } // resolve for Promise keyProvider = await Promise . resolve ( keyProvider ) ; if ( ! Array . isArray ( keyProvider ) ) { keyProvider = [ keyProvider ] ; } for ( let key of keyProvider ) { if ( ! EvtKey . isValidPrivateKey ( key ) ) { throw new Error ( "Invalid private key" ) ; } } return keyProvider ; }


Input: Additional forms of entropy are used . A week random number generator can run out of entropy . This should ensure even the worst random number implementation will be reasonably safe . [CODESPLIT] function random32ByteBuffer ( { cpuEntropyBits = 0 , safe = true } = { } ) { assert . equal ( typeof cpuEntropyBits , "number" , "cpuEntropyBits" ) ; assert . equal ( typeof safe , "boolean" , "boolean" ) ; if ( safe ) { assert ( entropyCount >= 128 , "Call initialize() to add entropy (current: " + entropyCount + ")" ) ; } // if(entropyCount > 0) { //     console.log(`Additional private key entropy: ${entropyCount} events`) // } const hash_array = [ ] ; hash_array . push ( randomBytes ( 32 ) ) ; hash_array . push ( Buffer . from ( cpuEntropy ( cpuEntropyBits ) ) ) ; hash_array . push ( externalEntropyArray ) ; hash_array . push ( browserEntropy ( ) ) ; return hash . sha256 ( Buffer . concat ( hash_array ) ) ; }


Input: Adds entropy . This may be called many times while the amount of data saved is accumulatively reduced to 101 integers . Data is retained in RAM for the life of this module . [CODESPLIT] function addEntropy ( ... ints ) { assert . equal ( externalEntropyArray . length , 101 , "externalEntropyArray" ) ; entropyCount += ints . length ; for ( const i of ints ) { const pos = entropyPos ++ % 101 ; const i2 = externalEntropyArray [ pos ] += i ; if ( i2 > 9007199254740991 ) externalEntropyArray [ pos ] = 0 ; } }


Input: This runs in just under 1 second and ensures a minimum of cpuEntropyBits bits of entropy are gathered . [CODESPLIT] function cpuEntropy ( cpuEntropyBits = 128 ) { let collected = [ ] ; let lastCount = null ; let lowEntropySamples = 0 ; while ( collected . length < cpuEntropyBits ) { const count = floatingPointCount ( ) ; if ( lastCount != null ) { const delta = count - lastCount ; if ( Math . abs ( delta ) < 1 ) { lowEntropySamples ++ ; continue ; } // how many bits of entropy were in this sample const bits = Math . floor ( log2 ( Math . abs ( delta ) ) + 1 ) ; if ( bits < 4 ) { if ( bits < 2 ) { lowEntropySamples ++ ; } continue ; } collected . push ( delta ) ; } lastCount = count ; } if ( lowEntropySamples > 10 ) { const pct = Number ( lowEntropySamples / cpuEntropyBits * 100 ) . toFixed ( 2 ) ; // Is this algorithm getting inefficient? console . warn ( ` ${ pct } ` ) ; } return collected ; }


Input: @private Attempt to gather and hash information from the browser s window history and supported mime types . For non - browser environments this simply includes secure random data . In any event the information is re - hashed in a loop for 25 milliseconds seconds . [CODESPLIT] function browserEntropy ( ) { let entropyStr = Array ( randomBytes ( 101 ) ) . join ( ) ; try { entropyStr += ( new Date ( ) ) . toString ( ) + " " + window . screen . height + " " + window . screen . width + " " + window . screen . colorDepth + " " + " " + window . screen . availHeight + " " + window . screen . availWidth + " " + window . screen . pixelDepth + navigator . language + " " + window . location + " " + window . history . length ; for ( let i = 0 , mimeType ; i < navigator . mimeTypes . length ; i ++ ) { mimeType = navigator . mimeTypes [ i ] ; entropyStr += mimeType . description + " " + mimeType . type + " " + mimeType . suffixes + " " ; } } catch ( error ) { //nodejs:ReferenceError: window is not defined entropyStr += hash . sha256 ( ( new Date ( ) ) . toString ( ) ) ; } const b = new Buffer ( entropyStr ) ; entropyStr += b . toString ( "binary" ) + " " + ( new Date ( ) ) . toString ( ) ; let entropy = entropyStr ; const start_t = Date . now ( ) ; while ( Date . now ( ) - start_t < 25 ) entropy = hash . sha256 ( entropy ) ; return entropy ; }


Input: Spec : http : // localhost : 3002 / steem / @dantheman / how - to - encrypt - a - memo - when - transferring - steem [CODESPLIT] function encrypt ( private_key , public_key , message , nonce = uniqueNonce ( ) ) { return crypt ( private_key , public_key , nonce , message ) ; }


Input: Spec : http : // localhost : 3002 / steem / @dantheman / how - to - encrypt - a - memo - when - transferring - steem [CODESPLIT] function decrypt ( private_key , public_key , nonce , message , checksum ) { return crypt ( private_key , public_key , nonce , message , checksum ) . message ; }


Input: This method does not use a checksum the returned data must be validated some other way . [CODESPLIT] function cryptoJsDecrypt ( message , key , iv ) { assert ( message , "Missing cipher text" ) ; message = toBinaryBuffer ( message ) ; const decipher = crypto . createDecipheriv ( "aes-256-cbc" , key , iv ) ; // decipher.setAutoPadding(true) message = Buffer . concat ( [ decipher . update ( message ) , decipher . final ( ) ] ) ; return message ; }


Input: This method does not use a checksum the returned data must be validated some other way . @arg { string|Buffer } message - plaintext binary format @arg { string<utf8 > |Buffer } key - 256bit @arg { string<utf8 > |Buffer } iv - 128bit [CODESPLIT] function cryptoJsEncrypt ( message , key , iv ) { assert ( message , "Missing plain text" ) ; message = toBinaryBuffer ( message ) ; const cipher = crypto . createCipheriv ( "aes-256-cbc" , key , iv ) ; // cipher.setAutoPadding(true) message = Buffer . concat ( [ cipher . update ( message ) , cipher . final ( ) ] ) ; return message ; }


Input: ECIES [CODESPLIT] function getSharedSecret ( public_key ) { public_key = PublicKey ( public_key ) ; let KB = public_key . toUncompressed ( ) . toBuffer ( ) ; let KBP = Point . fromAffine ( secp256k1 , BigInteger . fromBuffer ( KB . slice ( 1 , 33 ) ) , // x BigInteger . fromBuffer ( KB . slice ( 33 , 65 ) ) // y ) ; let r = toBuffer ( ) ; let P = KBP . multiply ( BigInteger . fromBuffer ( r ) ) ; let S = P . affineX . toBuffer ( { size : 32 } ) ; // SHA512 used in ECIES return hash . sha512 ( S ) ; }


Input: / ** ECIES TODO unit test @arg { string|Object } pubkey wif PublicKey object @return { Buffer } 64 byte shared secret function getSharedSecret ( public_key ) { public_key = PublicKey ( public_key ) . toUncompressed () var P = public_key . Q . multiply ( d ) ; var S = P . affineX . toBuffer ( { size : 32 } ) ; // ECIES adds an extra sha512 return hash . sha512 ( S ) ; } @arg { string } name - child key name . @return { PrivateKey } [CODESPLIT] function getChildKey ( name ) { // console.error('WARNING: getChildKey untested against evtd'); // no evtd impl yet const index = createHash ( "sha256" ) . update ( toBuffer ( ) ) . update ( name ) . digest ( ) ; return PrivateKey ( index ) ; }


Input: Run self - checking code and gather CPU entropy . [CODESPLIT] function initialize ( ) { if ( initialized ) { return ; } unitTest ( ) ; keyUtils . addEntropy ( ... keyUtils . cpuEntropy ( ) ) ; assert ( keyUtils . entropyCount ( ) >= 128 , "insufficient entropy" ) ; initialized = true ; }


Input: am1 : use a single mult and divide to get the high bits max digit bits should be 26 because max internal value = 2 * dvalue^2 - 2 * dvalue ( < 2^53 ) [CODESPLIT] function am1 ( i , x , w , j , c , n ) { while ( -- n >= 0 ) { var v = x * this [ i ++ ] + w [ j ] + c c = Math . floor ( v / 0x4000000 ) w [ j ++ ] = v & 0x3ffffff } return c }


Input: am2 avoids a big mult - and - extract completely . Max digit bits should be < = 30 because we do bitwise ops on values up to 2 * hdvalue^2 - hdvalue - 1 ( < 2^31 ) [CODESPLIT] function am2 ( i , x , w , j , c , n ) { var xl = x & 0x7fff , xh = x >> 15 while ( -- n >= 0 ) { var l = this [ i ] & 0x7fff var h = this [ i ++ ] >> 15 var m = xh * l + h * xl l = xl * l + ( ( m & 0x7fff ) << 15 ) + w [ j ] + ( c & 0x3fffffff ) c = ( l >>> 30 ) + ( m >>> 15 ) + xh * h + ( c >>> 30 ) w [ j ++ ] = l & 0x3fffffff } return c }


Input: ( protected ) copy this to r [CODESPLIT] function bnpCopyTo ( r ) { for ( var i = this . t - 1 ; i >= 0 ; -- i ) r [ i ] = this [ i ] r . t = this . t r . s = this . s }


Input: ( protected ) return - 1 / this % 2^DB ; useful for Mont . reduction justification : xy == 1 ( mod m ) xy = 1 + km xy ( 2 - xy ) = ( 1 + km ) ( 1 - km ) x [ y ( 2 - xy ) ] = 1 - k^2m^2 x [ y ( 2 - xy ) ] == 1 ( mod m^2 ) if y is 1 / x mod m then y ( 2 - xy ) is 1 / x mod m^2 should reduce x and y ( 2 - xy ) by m^2 at each step to keep size bounded . JS multiply overflows differently from C / C ++ so care is needed here . [CODESPLIT] function bnpInvDigit ( ) { if ( this . t < 1 ) return 0 var x = this [ 0 ] if ( ( x & 1 ) == 0 ) return 0 var y = x & 3 ; // y == 1/x mod 2^2 y = ( y * ( 2 - ( x & 0xf ) * y ) ) & 0xf ; // y == 1/x mod 2^4 y = ( y * ( 2 - ( x & 0xff ) * y ) ) & 0xff ; // y == 1/x mod 2^8 y = ( y * ( 2 - ( ( ( x & 0xffff ) * y ) & 0xffff ) ) ) & 0xffff ; // y == 1/x mod 2^16 // last step - calculate inverse mod DV directly // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints y = ( y * ( 2 - x * y % this . DV ) ) % this . DV ; // y == 1/x mod 2^dbits // we really want the negative inverse, and -DV < y < DV return ( y > 0 ) ? this . DV - y : - y }


Input: Montgomery reduction [CODESPLIT] function Montgomery ( m ) { this . m = m this . mp = m . invDigit ( ) this . mpl = this . mp & 0x7fff this . mph = this . mp >> 15 this . um = ( 1 << ( m . DB - 15 ) ) - 1 this . mt2 = 2 * m . t }


Input: xR mod m [CODESPLIT] function montConvert ( x ) { var r = new BigInteger ( ) x . abs ( ) . dlShiftTo ( this . m . t , r ) r . divRemTo ( this . m , null , r ) if ( x . s < 0 && r . compareTo ( BigInteger . ZERO ) > 0 ) this . m . subTo ( r , r ) return r }


Input: x / R mod m [CODESPLIT] function montRevert ( x ) { var r = new BigInteger ( ) x . copyTo ( r ) this . reduce ( r ) return r }


Input: ( public ) ~this [CODESPLIT] function bnNot ( ) { var r = new BigInteger ( ) for ( var i = 0 ; i < this . t ; ++ i ) r [ i ] = this . DM & ~ this [ i ] r . t = this . t r . s = ~ this . s return r }


Input: ( public ) this << n [CODESPLIT] function bnShiftLeft ( n ) { var r = new BigInteger ( ) if ( n < 0 ) this . rShiftTo ( - n , r ) else this . lShiftTo ( n , r ) return r }


Input: ( public ) this >> n [CODESPLIT] function bnShiftRight ( n ) { var r = new BigInteger ( ) if ( n < 0 ) this . lShiftTo ( - n , r ) else this . rShiftTo ( n , r ) return r }


Input: ( protected ) this op ( 1<<n ) [CODESPLIT] function bnpChangeBit ( n , op ) { var r = BigInteger . ONE . shiftLeft ( n ) this . bitwiseTo ( r , op , r ) return r }


Input: ( public ) [ this / a this%a ] [CODESPLIT] function bnDivideAndRemainder ( a ) { var q = new BigInteger ( ) , r = new BigInteger ( ) this . divRemTo ( a , q , r ) return new Array ( q , r ) }


Input: x = x mod m ( HAC 14 . 42 ) [CODESPLIT] function barrettReduce ( x ) { var self = this x . drShiftTo ( self . m . t - 1 , self . r2 ) if ( x . t > self . m . t + 1 ) { x . t = self . m . t + 1 x . clamp ( ) } self . mu . multiplyUpperTo ( self . r2 , self . m . t + 1 , self . q3 ) self . m . multiplyLowerTo ( self . q3 , self . m . t + 1 , self . r2 ) while ( x . compareTo ( self . r2 ) < 0 ) x . dAddOffset ( 1 , self . m . t + 1 ) x . subTo ( self . r2 , x ) while ( x . compareTo ( self . m ) >= 0 ) x . subTo ( self . m , x ) }


Input: ( public ) this^e % m ( HAC 14 . 85 ) [CODESPLIT] function bnModPow ( e , m ) { var i = e . bitLength ( ) , k , r = nbv ( 1 ) , z if ( i <= 0 ) return r else if ( i < 18 ) k = 1 else if ( i < 48 ) k = 3 else if ( i < 144 ) k = 4 else if ( i < 768 ) k = 5 else k = 6 if ( i < 8 ) z = new Classic ( m ) else if ( m . isEven ( ) ) z = new Barrett ( m ) else z = new Montgomery ( m ) // precomputation var g = new Array ( ) , n = 3 , k1 = k - 1 , km = ( 1 << k ) - 1 g [ 1 ] = z . convert ( this ) if ( k > 1 ) { var g2 = new BigInteger ( ) z . sqrTo ( g [ 1 ] , g2 ) while ( n <= km ) { g [ n ] = new BigInteger ( ) z . mulTo ( g2 , g [ n - 2 ] , g [ n ] ) n += 2 } } var j = e . t - 1 , w , is1 = true , r2 = new BigInteger ( ) , t i = nbits ( e [ j ] ) - 1 while ( j >= 0 ) { if ( i >= k1 ) w = ( e [ j ] >> ( i - k1 ) ) & km else { w = ( e [ j ] & ( ( 1 << ( i + 1 ) ) - 1 ) ) << ( k1 - i ) if ( j > 0 ) w |= e [ j - 1 ] >> ( this . DB + i - k1 ) } n = k while ( ( w & 1 ) == 0 ) { w >>= 1 -- n } if ( ( i -= n ) < 0 ) { i += this . DB -- j } if ( is1 ) { // ret == 1, don't bother squaring or multiplying it g [ w ] . copyTo ( r ) is1 = false } else { while ( n > 1 ) { z . sqrTo ( r , r2 ) z . sqrTo ( r2 , r ) n -= 2 } if ( n > 0 ) z . sqrTo ( r , r2 ) else { t = r r = r2 r2 = t } z . mulTo ( r2 , g [ w ] , r ) } while ( j >= 0 && ( e [ j ] & ( 1 << i ) ) == 0 ) { z . sqrTo ( r , r2 ) t = r r = r2 r2 = t if ( -- i < 0 ) { i = this . DB - 1 -- j } } } return z . revert ( r ) }


Input: ( public ) gcd ( this a ) ( HAC 14 . 54 ) [CODESPLIT] function bnGCD ( a ) { var x = ( this . s < 0 ) ? this . negate ( ) : this . clone ( ) var y = ( a . s < 0 ) ? a . negate ( ) : a . clone ( ) if ( x . compareTo ( y ) < 0 ) { var t = x x = y y = t } var i = x . getLowestSetBit ( ) , g = y . getLowestSetBit ( ) if ( g < 0 ) return x if ( i < g ) g = i if ( g > 0 ) { x . rShiftTo ( g , x ) y . rShiftTo ( g , y ) } while ( x . signum ( ) > 0 ) { if ( ( i = x . getLowestSetBit ( ) ) > 0 ) x . rShiftTo ( i , x ) if ( ( i = y . getLowestSetBit ( ) ) > 0 ) y . rShiftTo ( i , y ) if ( x . compareTo ( y ) >= 0 ) { x . subTo ( y , x ) x . rShiftTo ( 1 , x ) } else { y . subTo ( x , y ) y . rShiftTo ( 1 , y ) } } if ( g > 0 ) y . lShiftTo ( g , y ) return y }


Input: ( protected ) this % n n < 2^26 [CODESPLIT] function bnpModInt ( n ) { if ( n <= 0 ) return 0 var d = this . DV % n , r = ( this . s < 0 ) ? n - 1 : 0 if ( this . t > 0 ) if ( d == 0 ) r = this [ 0 ] % n else for ( var i = this . t - 1 ; i >= 0 ; -- i ) r = ( d * r + this [ i ] ) % n return r }


Input: ( public ) test primality with certainty > = 1 - . 5^t [CODESPLIT] function bnIsProbablePrime ( t ) { var i , x = this . abs ( ) if ( x . t == 1 && x [ 0 ] <= lowprimes [ lowprimes . length - 1 ] ) { for ( i = 0 ; i < lowprimes . length ; ++ i ) if ( x [ 0 ] == lowprimes [ i ] ) return true return false } if ( x . isEven ( ) ) return false i = 1 while ( i < lowprimes . length ) { var m = lowprimes [ i ] , j = i + 1 while ( j < lowprimes . length && m < lplim ) m *= lowprimes [ j ++ ] m = x . modInt ( m ) while ( i < j ) if ( m % lowprimes [ i ++ ] == 0 ) return false } return x . millerRabin ( t ) }


Input: Verify signed data . [CODESPLIT] function verify ( data , pubkey , encoding = "utf8" ) { if ( typeof data === "string" ) { data = Buffer . from ( data , encoding ) ; } assert ( Buffer . isBuffer ( data ) , "data is a required String or Buffer" ) ; data = hash . sha256 ( data ) ; return verifyHash ( data , pubkey ) ; }


Input: Verify a buffer of exactally 32 bytes in size ( sha256 ( text )) [CODESPLIT] function verifyHash ( dataSha256 , pubkey , encoding = "hex" ) { if ( typeof dataSha256 === "string" ) { dataSha256 = Buffer . from ( dataSha256 , encoding ) ; } if ( dataSha256 . length !== 32 || ! Buffer . isBuffer ( dataSha256 ) ) throw new Error ( "dataSha256: 32 bytes required" ) ; const publicKey = PublicKey ( pubkey ) ; assert ( publicKey , "pubkey required" ) ; return ecdsa . verify ( curve , dataSha256 , { r : r , s : s } , publicKey . Q ) ; }


Input: Recover the public key used to create this signature using full data . [CODESPLIT] function recover ( data , encoding = "utf8" ) { if ( typeof data === "string" ) { data = Buffer . from ( data , encoding ) ; } assert ( Buffer . isBuffer ( data ) , "data is a required String or Buffer" ) ; data = hash . sha256 ( data ) ; return recoverHash ( data ) ; }


Input: @arg { String|Buffer } dataSha256 - sha256 hash 32 byte buffer or hex string @arg { String } [ encoding = hex ] - dataSha256 encoding ( if string ) [CODESPLIT] function recoverHash ( dataSha256 , encoding = "hex" ) { //let time = new Date().valueOf(); if ( typeof dataSha256 === "string" ) { dataSha256 = Buffer . from ( dataSha256 , encoding ) ; } if ( dataSha256 . length !== 32 || ! Buffer . isBuffer ( dataSha256 ) ) { throw new Error ( "dataSha256: 32 byte String or buffer requred" ) ; } // sign the message if ( secp256k1 != null ) { let buffer = toBuffer ( ) ; //console.log("[recoverHash] accelerating supported, length of sign: " + buffer.length); var ret = PublicKey . fromBuffer ( secp256k1 . recover ( dataSha256 , buffer . slice ( 1 ) , buffer [ 0 ] - 4 - 27 , true ) ) ; //time = (new Date().valueOf()) - time; //console.log("[+" + time + "ms] recoverHash (c binding)"); return ret ; } else { //console.log("[recoverHash] accelerating not supported"); const e = BigInteger . fromBuffer ( dataSha256 ) ; let i2 = i ; i2 -= 27 ; i2 = i2 & 3 ; const Q = ecdsa . recoverPubKey ( curve , e , { r , s , i } , i2 ) ; // time = (new Date().valueOf()) - time; //console.log("[+" + time + "ms] recoverHash"); return PublicKey . fromPoint ( Q ) ; } }


Input: Original Name encode and decode logic is in github . com / eosio / eos native . hpp Encode a name ( a base32 string ) to a number . [CODESPLIT] function encodeName ( name , littleEndian = true ) { if ( typeof name !== "string" ) throw new TypeError ( "name parameter is a required string" ) ; if ( name . length > 13 ) throw new TypeError ( "A name can be up to 13 characters long" ) ; let bitstr = "" ; for ( let i = 0 ; i <= 12 ; i ++ ) { // process all 64 bits (even if name is short) const c = i < name . length ? charidx ( name [ i ] ) : 0 ; const bitlen = i < 12 ? 5 : 4 ; let bits = Number ( c ) . toString ( 2 ) ; if ( bits . length > bitlen ) { throw new TypeError ( "Invalid name " + name ) ; } bits = "0" . repeat ( bitlen - bits . length ) + bits ; bitstr += bits ; } const value = Long . fromString ( bitstr , true , 2 ) ; // convert to LITTLE_ENDIAN let leHex = "" ; const bytes = littleEndian ? value . toBytesLE ( ) : value . toBytesBE ( ) ; for ( const b of bytes ) { const n = Number ( b ) . toString ( 16 ) ; leHex += ( n . length === 1 ? "0" : "" ) + n ; } const ulName = Long . fromString ( leHex , true , 16 ) . toString ( ) ; // console.log('encodeName', name, value.toString(), ulName.toString(), JSON.stringify(bitstr.split(/(.....)/).slice(1))) return ulName . toString ( ) ; }


Input: Encode a name ( a base32 string ) to a number . [CODESPLIT] function encodeName128 ( name ) { if ( typeof name !== 'string' ) throw new TypeError ( 'name parameter is a required string' ) ; if ( name . length > 21 ) throw new TypeError ( 'A name can be up to 21 characters long' ) ; let bitstr = '' ; for ( let i = 0 ; i < 21 ; i ++ ) { // process all 64 bits (even if name is short) const c = i < name . length ? charidx128 ( name [ i ] ) : 0 ; let bits = Number ( c ) . toString ( 2 ) ; if ( bits . length > 6 ) { throw new TypeError ( 'Invalid name ' + name ) ; } bits = '0' . repeat ( 6 - bits . length ) + bits ; bitstr = bits + bitstr ; } let cutSize = 4 ; if ( name . length <= 5 ) { bitstr += "00" cutSize = 4 } else if ( name . length <= 10 ) { bitstr += "01" cutSize = 8 } else if ( name . length <= 15 ) { bitstr += "10" cutSize = 12 } else { bitstr += "11" cutSize = 16 } let bn = new BN ( bitstr , 2 ) ; // bn = bn.toTwos(128); return bn . toArrayLike ( Buffer , 'le' , 128 / 8 / 16 * cutSize ) ; }


Input: The authenticate function is called whenever ZAP requires to authenticate for a Context for which this script was selected as the Authentication Method . The function should send any messages that are required to do the authentication and should return a message with an authenticated response so the calling method . NOTE : Any message sent in the function should be obtained using the helper . prepareMessage () method . Parameters : helper - a helper class providing useful methods : prepareMessage () sendAndReceive ( msg ) getHttpSender () paramsValues - the values of the parameters configured in the Session Properties - > Authentication panel . The paramsValues is a map having as keys the parameters names ( as returned by the getRequiredParamsNames () and getOptionalParamsNames () functions below ) credentials - an object containing the credentials values as configured in the Session Properties - > Users panel . The credential values can be obtained via calls to the getParam ( paramName ) method . The param names are the ones returned by the getCredentialsParamsNames () below [CODESPLIT] function authenticate ( helper , paramsValues , credentials ) { print ( "Authenticating via JavaScript script..." ) ; var msg = helper . prepareMessage ( ) ; // TODO: Process message to match the authentication needs // Configurations on how the messages are sent/handled: // Set to follow redirects when sending messages (default is false). // helper.getHttpSender().setFollowRedirect(true) // Send message without following redirects (overriding the option previously set). // helper.sendAndReceive(msg, false) // Set the number of maximum redirects followed to 5 (default is 100). Main purpose is to prevent infinite loops. // helper.getHttpSender().setMaxRedirects(5) // Allow circular redirects (default is not allow). Circular redirects happen when a request // redirects to itself, or when a same request was already accessed in a chain of redirects. // helper.getHttpSender().setAllowCircularRedirects(true) helper . sendAndReceive ( msg ) ; return msg ; }


Input: The authenticate function is called whenever ZAP requires to authenticate for a Context for which this script was selected as the Authentication Method . The function should send any messages that are required to do the authentication and should return a message with an authenticated response so the calling method . NOTE : Any message sent in the function should be obtained using the helper . prepareMessage () method . Parameters : helper - a helper class providing useful methods : prepareMessage () sendAndReceive ( msg ) paramsValues - the values of the parameters configured in the Session Properties - > Authentication panel . The paramsValues is a map having as keys the parameters names ( as returned by the getRequiredParamsNames () and getOptionalParamsNames () functions below ) credentials - an object containing the credentials values as configured in the Session Properties - > Users panel . The credential values can be obtained via calls to the getParam ( paramName ) method . The param names are the ones returned by the getCredentialsParamsNames () below [CODESPLIT] function authenticate ( helper , paramsValues , credentials ) { print ( "Authenticating via JavaScript script..." ) ; // Make sure any Java classes used explicitly are imported var HttpRequestHeader = Java . type ( "org.parosproxy.paros.network.HttpRequestHeader" ) var HttpHeader = Java . type ( "org.parosproxy.paros.network.HttpHeader" ) var URI = Java . type ( "org.apache.commons.httpclient.URI" ) // Prepare the login request details var requestUri = new URI ( paramsValues . get ( "Target URL" ) , false ) ; var requestMethod = HttpRequestHeader . POST ; // Build the request body using the credentials values var extraPostData = paramsValues . get ( "Extra POST data" ) ; var requestBody = paramsValues . get ( "Username field" ) + "=" + encodeURIComponent ( credentials . getParam ( "Username" ) ) ; requestBody += "&" + paramsValues . get ( "Password field" ) + "=" + encodeURIComponent ( credentials . getParam ( "Password" ) ) ; if ( extraPostData . trim ( ) . length ( ) > 0 ) requestBody += "&" + extraPostData . trim ( ) ; // Build the actual message to be sent print ( "Sending " + requestMethod + " request to " + requestUri + " with body: " + requestBody ) ; var msg = helper . prepareMessage ( ) ; msg . setRequestHeader ( new HttpRequestHeader ( requestMethod , requestUri , HttpHeader . HTTP10 ) ) ; msg . setRequestBody ( requestBody ) ; // Send the authentication message and return it helper . sendAndReceive ( msg ) ; print ( "Received response status code: " + msg . getResponseHeader ( ) . getStatusCode ( ) ) ; return msg ; }


Input: Targeted scripts can only be invoked by you the user eg via a right - click option on the Sites or History tabs [CODESPLIT] function invokeWith ( msg ) { // Debugging can be done using println like this print ( 'Finding comments in ' + msg . getRequestHeader ( ) . getURI ( ) . toString ( ) ) ; var body = msg . getResponseBody ( ) . toString ( ) // Look for html comments if ( body . indexOf ( '<!--' ) > 0 ) { var o = body . indexOf ( '<!--' ) ; while ( o > 0 ) { var e = body . indexOf ( '-->' , o ) ; print ( "\t" + body . substr ( o , e - o + 3 ) ) o = body . indexOf ( '<!--' , e ) ; } } }


Input: Passively scans an HTTP message . The scan function will be called for request / response made via ZAP actual messages depend on the function appliesToHistoryType defined below . [CODESPLIT] function scan ( ps , msg , src ) { // Test the request and/or response here if ( true ) { // Change to a test which detects the vulnerability // raiseAlert(risk, int confidence, String name, String description, String uri,  //		String param, String attack, String otherInfo, String solution, String evidence,  //		int cweId, int wascId, HttpMessage msg) // risk: 0: info, 1: low, 2: medium, 3: high // confidence: 0: falsePositive, 1: low, 2: medium, 3: high, 4: confirmed ps . raiseAlert ( 1 , 1 , 'Passive Vulnerability title' , 'Full description' , msg . getRequestHeader ( ) . getURI ( ) . toString ( ) , 'The param' , 'Your attack' , 'Any other info' , 'The solution' , '' , 'References' , 0 , 0 , msg ) ; //addTag(String tag) ps . addTag ( 'tag' ) } // Raise less reliable alert (that is, prone to false positives) when in LOW alert threshold // Expected values: "LOW", "MEDIUM", "HIGH" if ( ps . getAlertThreshold ( ) == "LOW" ) { // ... } }


Input: The authenticate function is called whenever ZAP requires to authenticate for a Context for which this script was selected as the Authentication Method . The function should send any messages that are required to do the authentication and should return a message with an authenticated response so the calling method . NOTE : Any message sent in the function should be obtained using the helper . prepareMessage () method . Parameters : helper - a helper class providing useful methods : prepareMessage () sendAndReceive ( msg ) paramsValues - the values of the parameters configured in the Session Properties - > Authentication panel . The paramsValues is a map having as keys the parameters names ( as returned by the getRequiredParamsNames () and getOptionalParamsNames () functions below ) credentials - an object containing the credentials values as configured in the Session Properties - > Users panel . The credential values can be obtained via calls to the getParam ( paramName ) method . The param names are the ones returned by the getCredentialsParamsNames () below [CODESPLIT] function authenticate ( helper , paramsValues , credentials ) { print ( "Wordpress Authenticating via JavaScript script..." ) ; // Make sure any Java classes used explicitly are imported var HttpRequestHeader = Java . type ( "org.parosproxy.paros.network.HttpRequestHeader" ) var HttpHeader = Java . type ( "org.parosproxy.paros.network.HttpHeader" ) var URI = Java . type ( "org.apache.commons.httpclient.URI" ) var Cookie = Java . type ( "org.apache.commons.httpclient.Cookie" ) // Prepare the login request details var domain = paramsValues . get ( "Domain" ) ; var path = paramsValues . get ( "Path" ) ; print ( "Logging in to domain " + domain + " and path " + path ) ; var requestUri = new URI ( "http://" + domain + path + "wp-login.php" , false ) ; var requestMethod = HttpRequestHeader . POST ; // Build the request body using the credentials values var requestBody = "log=" + encodeURIComponent ( credentials . getParam ( "Username" ) ) ; requestBody = requestBody + "&pwd=" + encodeURIComponent ( credentials . getParam ( "Password" ) ) ; requestBody = requestBody + "&rememberme=forever&wp-submit=Log+In&testcookie=1" ; // Add the proper cookie to the header var requestHeader = new HttpRequestHeader ( requestMethod , requestUri , HttpHeader . HTTP10 ) ; requestHeader . setHeader ( HttpHeader . COOKIE , "wordpress_test_cookie=WP+Cookie+check" ) ; // Build the actual message to be sent print ( "Sending " + requestMethod + " request to " + requestUri + " with body: " + requestBody ) ; var msg = helper . prepareMessage ( ) ; msg . setRequestHeader ( requestHeader ) ; msg . setRequestBody ( requestBody ) ; // Send the authentication message and return it helper . sendAndReceive ( msg ) ; print ( "Received response status code for authentication request: " + msg . getResponseHeader ( ) . getStatusCode ( ) ) ; // The path Wordpress sets on the session cookies is illegal according to the standard. The web browsers ignore this and use the cookies anyway, but the Apache Commons HttpClient used in ZAP really cares about this (probably the only one who does it) and simply ignores the "invalid" cookies [0] , [1],so we must make sure we MANUALLY add the response cookies if ( path != "/" && path . charAt ( path . length ( ) - 1 ) == '/' ) { path = path . substring ( 0 , path . length ( ) - 1 ) ; } print ( "Cleaned cookie path: " + path ) ; var cookies = msg . getResponseHeader ( ) . getCookieParams ( ) ; var state = helper . getCorrespondingHttpState ( ) ; for ( var iterator = cookies . iterator ( ) ; iterator . hasNext ( ) ; ) { var cookie = iterator . next ( ) ; print ( "Manually adding cookie: " + cookie . getName ( ) + " = " + cookie . getValue ( ) ) ; state . addCookie ( new Cookie ( domain , cookie . getName ( ) , cookie . getValue ( ) , path , 999999 , false ) ) ; } return msg ; }


Input:
A set of fields can appear grouped together . [CODESPLIT] function FormGroup ( props ) { const { children , className , grouped , inline , unstackable , widths } = props const classes = cx ( useKeyOnly ( grouped , 'grouped' ) , useKeyOnly ( inline , 'inline' ) , useKeyOnly ( unstackable , 'unstackable' ) , useWidthProp ( widths , null , true ) , 'fields' , className , ) const rest = getUnhandledProps ( FormGroup , props ) const ElementType = getElementType ( FormGroup , props ) return ( < ElementType { ... rest } className = { classes } >
       { children }
     < / ElementType > ) }


Input:
A loader alerts a user to wait for an activity to complete . [CODESPLIT] function Loader ( props ) { const { active , children , className , content , disabled , indeterminate , inline , inverted , size , } = props const classes = cx ( 'ui' , size , useKeyOnly ( active , 'active' ) , useKeyOnly ( disabled , 'disabled' ) , useKeyOnly ( indeterminate , 'indeterminate' ) , useKeyOnly ( inverted , 'inverted' ) , useKeyOnly ( children || content , 'text' ) , useKeyOrValueAndKey ( inline , 'inline' ) , 'loader' , className , ) const rest = getUnhandledProps ( Loader , props ) const ElementType = getElementType ( Loader , props ) return ( < ElementType { ... rest } className = { classes } >
       { childrenUtils . isNil ( children ) ? content : children }
     < / ElementType > ) }


Input: Sugar for <Form . Field control = { TextArea } / > . [CODESPLIT] function FormTextArea ( props ) { const { control } = props const rest = getUnhandledProps ( FormTextArea , props ) const ElementType = getElementType ( FormTextArea , props ) return < ElementType { ... rest } control = { control } / > }


Input: Sugar for <Form . Field control = { Select } / > . [CODESPLIT] function FormSelect ( props ) { const { control , options } = props const rest = getUnhandledProps ( FormSelect , props ) const ElementType = getElementType ( FormSelect , props ) return < ElementType { ... rest } control = { control } options = { options } / > }


Input:
An item can contain content . [CODESPLIT] function ItemContent ( props ) { const { children , className , content , description , extra , header , meta , verticalAlign } = props const classes = cx ( useVerticalAlignProp ( verticalAlign ) , 'content' , className ) const rest = getUnhandledProps ( ItemContent , props ) const ElementType = getElementType ( ItemContent , props ) if ( ! childrenUtils . isNil ( children ) ) { return ( < ElementType { ... rest } className = { classes } >
         { children }
       < / ElementType > ) } return ( < ElementType { ... rest } className = { classes } >
       { ItemHeader . create ( header , { autoGenerateKey : false } ) }
       { ItemMeta . create ( meta , { autoGenerateKey : false } ) }
       { ItemDescription . create ( description , { autoGenerateKey : false } ) }
       { ItemExtra . create ( extra , { autoGenerateKey : false } ) }
       { content }
     < / ElementType > ) }


Input:
A table displays a collections of data grouped into rows . [CODESPLIT] function Table ( props ) { const { attached , basic , celled , children , className , collapsing , color , columns , compact , definition , fixed , footerRow , headerRow , headerRows , inverted , padded , renderBodyRow , selectable , singleLine , size , sortable , stackable , striped , structured , tableData , textAlign , unstackable , verticalAlign , } = props const classes = cx ( 'ui' , color , size , useKeyOnly ( celled , 'celled' ) , useKeyOnly ( collapsing , 'collapsing' ) , useKeyOnly ( definition , 'definition' ) , useKeyOnly ( fixed , 'fixed' ) , useKeyOnly ( inverted , 'inverted' ) , useKeyOnly ( selectable , 'selectable' ) , useKeyOnly ( singleLine , 'single line' ) , useKeyOnly ( sortable , 'sortable' ) , useKeyOnly ( stackable , 'stackable' ) , useKeyOnly ( striped , 'striped' ) , useKeyOnly ( structured , 'structured' ) , useKeyOnly ( unstackable , 'unstackable' ) , useKeyOrValueAndKey ( attached , 'attached' ) , useKeyOrValueAndKey ( basic , 'basic' ) , useKeyOrValueAndKey ( compact , 'compact' ) , useKeyOrValueAndKey ( padded , 'padded' ) , useTextAlignProp ( textAlign ) , useVerticalAlignProp ( verticalAlign ) , useWidthProp ( columns , 'column' ) , 'table' , className , ) const rest = getUnhandledProps ( Table , props ) const ElementType = getElementType ( Table , props ) if ( ! childrenUtils . isNil ( children ) ) { return ( < ElementType { ... rest } className = { classes } >
         { children }
       < / ElementType > ) } const hasHeaderRows = headerRow || headerRows const headerShorthandOptions = { defaultProps : { cellAs : 'th' } } const headerElement = hasHeaderRows && ( < TableHeader >
       { TableRow . create ( headerRow , headerShorthandOptions ) }
       { _ . map ( headerRows , ( data ) => TableRow . create ( data , headerShorthandOptions ) ) }
     < / TableHeader > ) return ( < ElementType { ... rest } className = { classes } >
       { headerElement }
       < TableBody >
         { renderBodyRow && _ . map ( tableData , ( data , index ) => TableRow . create ( renderBodyRow ( data , index ) ) ) }
       < / TableBody >
       { footerRow && < TableFooter > { TableRow . create ( footerRow ) } < / TableFooter > }
     < / ElementType > ) }


Input:
A rail is used to show accompanying content outside the boundaries of the main view of a site . [CODESPLIT] function Rail ( props ) { const { attached , children , className , close , content , dividing , internal , position , size , } = props const classes = cx ( 'ui' , position , size , useKeyOnly ( attached , 'attached' ) , useKeyOnly ( dividing , 'dividing' ) , useKeyOnly ( internal , 'internal' ) , useKeyOrValueAndKey ( close , 'close' ) , 'rail' , className , ) const rest = getUnhandledProps ( Rail , props ) const ElementType = getElementType ( Rail , props ) return ( < ElementType { ... rest } className = { classes } >
       { childrenUtils . isNil ( children ) ? content : children }
     < / ElementType > ) }


Input:
Buttons can be grouped . [CODESPLIT] function ButtonGroup ( props ) { const { attached , basic , buttons , children , className , color , compact , content , floated , fluid , icon , inverted , labeled , negative , positive , primary , secondary , size , toggle , vertical , widths , } = props const classes = cx ( 'ui' , color , size , useKeyOnly ( basic , 'basic' ) , useKeyOnly ( compact , 'compact' ) , useKeyOnly ( fluid , 'fluid' ) , useKeyOnly ( icon , 'icon' ) , useKeyOnly ( inverted , 'inverted' ) , useKeyOnly ( labeled , 'labeled' ) , useKeyOnly ( negative , 'negative' ) , useKeyOnly ( positive , 'positive' ) , useKeyOnly ( primary , 'primary' ) , useKeyOnly ( secondary , 'secondary' ) , useKeyOnly ( toggle , 'toggle' ) , useKeyOnly ( vertical , 'vertical' ) , useKeyOrValueAndKey ( attached , 'attached' ) , useValueAndKey ( floated , 'floated' ) , useWidthProp ( widths ) , 'buttons' , className , ) const rest = getUnhandledProps ( ButtonGroup , props ) const ElementType = getElementType ( ButtonGroup , props ) if ( _ . isNil ( buttons ) ) { return ( < ElementType { ... rest } className = { classes } >
         { childrenUtils . isNil ( children ) ? content : children }
       < / ElementType > ) } return ( < ElementType { ... rest } className = { classes } >
       { _ . map ( buttons , button => Button . create ( button ) ) }
     < / ElementType > ) }


Input:
A row sub - component for Grid . [CODESPLIT] function GridRow ( props ) { const { centered , children , className , color , columns , divided , only , reversed , stretched , textAlign , verticalAlign , } = props const classes = cx ( color , useKeyOnly ( centered , 'centered' ) , useKeyOnly ( divided , 'divided' ) , useKeyOnly ( stretched , 'stretched' ) , useMultipleProp ( only , 'only' ) , useMultipleProp ( reversed , 'reversed' ) , useTextAlignProp ( textAlign ) , useVerticalAlignProp ( verticalAlign ) , useWidthProp ( columns , 'column' , true ) , 'row' , className , ) const rest = getUnhandledProps ( GridRow , props ) const ElementType = getElementType ( GridRow , props ) return ( < ElementType { ... rest } className = { classes } >
       { children }
     < / ElementType > ) }


Input:
A field is a form element containing a label and an input . [CODESPLIT] function FormField ( props ) { const { children , className , content , control , disabled , error , inline , label , required , type , width , } = props const classes = cx ( useKeyOnly ( disabled , 'disabled' ) , useKeyOnly ( error , 'error' ) , useKeyOnly ( inline , 'inline' ) , useKeyOnly ( required , 'required' ) , useWidthProp ( width , 'wide' ) , 'field' , className , ) const rest = getUnhandledProps ( FormField , props ) const ElementType = getElementType ( FormField , props ) // ---------------------------------------- // No Control // ---------------------------------------- if ( _ . isNil ( control ) ) { if ( _ . isNil ( label ) ) { return ( < ElementType { ... rest } className = { classes } >
           { childrenUtils . isNil ( children ) ? content : children }
         < / ElementType > ) } return ( < ElementType { ... rest } className = { classes } >
         { createHTMLLabel ( label , { autoGenerateKey : false } ) }
       < / ElementType > ) } // ---------------------------------------- // Checkbox/Radio Control // ---------------------------------------- const controlProps = { ... rest , content , children , disabled , required , type } // wrap HTML checkboxes/radios in the label if ( control === 'input' && ( type === 'checkbox' || type === 'radio' ) ) { return ( < ElementType className = { classes } >
         < label >
           { createElement ( control , controlProps ) }   { label }
         < / label >
       < / ElementType > ) } // pass label prop to controls that support it if ( control === Checkbox || control === Radio ) { return ( < ElementType className = { classes } >
         { createElement ( control , { ... controlProps , label } ) }
       < / ElementType > ) } // ---------------------------------------- // Other Control // ---------------------------------------- return ( < ElementType className = { classes } >
       { createHTMLLabel ( label , { defaultProps : { htmlFor : _ . get ( controlProps , 'id' ) } , autoGenerateKey : false , } ) }
       { createElement ( control , controlProps ) }
     < / ElementType > ) }


Input:
A card can contain blocks of content or extra content meant to be formatted separately from the main content . [CODESPLIT] function CardContent ( props ) { const { children , className , content , description , extra , header , meta , textAlign } = props const classes = cx ( useKeyOnly ( extra , 'extra' ) , useTextAlignProp ( textAlign ) , 'content' , className ) const rest = getUnhandledProps ( CardContent , props ) const ElementType = getElementType ( CardContent , props ) if ( ! childrenUtils . isNil ( children ) ) { return ( < ElementType { ... rest } className = { classes } >
         { children }
       < / ElementType > ) } if ( ! childrenUtils . isNil ( content ) ) { return ( < ElementType { ... rest } className = { classes } >
         { content }
       < / ElementType > ) } return ( < ElementType { ... rest } className = { classes } >
       { createShorthand ( CardHeader , val => ( { content : val } ) , header , { autoGenerateKey : false } ) }
       { createShorthand ( CardMeta , val => ( { content : val } ) , meta , { autoGenerateKey : false } ) }
       { createShorthand ( CardDescription , val => ( { content : val } ) , description , { autoGenerateKey : false , } ) }
     < / ElementType > ) }


Input:
An item view presents large collections of site content for display . [CODESPLIT] function Item ( props ) { const { children , className , content , description , extra , header , image , meta } = props const classes = cx ( 'item' , className ) const rest = getUnhandledProps ( Item , props ) const ElementType = getElementType ( Item , props ) if ( ! childrenUtils . isNil ( children ) ) { return ( < ElementType { ... rest } className = { classes } >
         { children }
       < / ElementType > ) } return ( < ElementType { ... rest } className = { classes } >
       { ItemImage . create ( image , { autoGenerateKey : false } ) }

       < ItemContent content = { content } description = { description } extra = { extra } header = { header } meta = { meta } / >
     < / ElementType > ) }


Input:
A comment can contain an image or avatar . [CODESPLIT] function CommentAvatar ( props ) { const { className , src } = props const classes = cx ( 'avatar' , className ) const rest = getUnhandledProps ( CommentAvatar , props ) const [ imageProps , rootProps ] = partitionHTMLProps ( rest , { htmlProps : htmlImageProps } ) const ElementType = getElementType ( CommentAvatar , props ) return ( < ElementType { ... rootProps } className = { classes } >
       { createHTMLImage ( src , { autoGenerateKey : false , defaultProps : imageProps } ) }
     < / ElementType > ) }


Input:
A statistic can contain a label to help provide context for the presented value . [CODESPLIT] function StatisticLabel ( props ) { const { children , className , content } = props const classes = cx ( 'label' , className ) const rest = getUnhandledProps ( StatisticLabel , props ) const ElementType = getElementType ( StatisticLabel , props ) return ( < ElementType { ... rest } className = { classes } >
       { childrenUtils . isNil ( children ) ? content : children }
     < / ElementType > ) }


Input: A Radio is sugar for <Checkbox radio / > . Useful for exclusive groups of sliders or toggles . [CODESPLIT] function Radio ( props ) { const { slider , toggle , type } = props const rest = getUnhandledProps ( Radio , props ) // const ElementType = getElementType(Radio, props) // radio, slider, toggle are exclusive // use an undefined radio if slider or toggle are present const radio = ! ( slider || toggle ) || undefined return < Checkbox { ... rest } type = { type } radio = { radio } slider = { slider } toggle = { toggle } / > }


Input: Sugar for <Form . Field control = { Checkbox } / > . [CODESPLIT] function FormCheckbox ( props ) { const { control } = props const rest = getUnhandledProps ( FormCheckbox , props ) const ElementType = getElementType ( FormCheckbox , props ) return < ElementType { ... rest } control = { control } / > }


Input:
A feed can contain a meta . [CODESPLIT] function FeedMeta ( props ) { const { children , className , content , like } = props const classes = cx ( 'meta' , className ) const rest = getUnhandledProps ( FeedMeta , props ) const ElementType = getElementType ( FeedMeta , props ) if ( ! childrenUtils . isNil ( children ) ) { return ( < ElementType { ... rest } className = { classes } >
         { children }
       < / ElementType > ) } return ( < ElementType { ... rest } className = { classes } >
       { createShorthand ( FeedLike , val => ( { content : val } ) , like , { autoGenerateKey : false } ) }
       { content }
     < / ElementType > ) }


Input:
A container limits content to a maximum width . [CODESPLIT] function Container ( props ) { const { children , className , content , fluid , text , textAlign } = props const classes = cx ( 'ui' , useKeyOnly ( text , 'text' ) , useKeyOnly ( fluid , 'fluid' ) , useTextAlignProp ( textAlign ) , 'container' , className , ) const rest = getUnhandledProps ( Container , props ) const ElementType = getElementType ( Container , props ) return ( < ElementType { ... rest } className = { classes } >
       { childrenUtils . isNil ( children ) ? content : children }
     < / ElementType > ) }


Input:
A set of steps . [CODESPLIT] function StepGroup ( props ) { const { attached , children , className , content , fluid , items , ordered , size , stackable , unstackable , vertical , widths , } = props const classes = cx ( 'ui' , size , useKeyOnly ( fluid , 'fluid' ) , useKeyOnly ( ordered , 'ordered' ) , useKeyOnly ( unstackable , 'unstackable' ) , useKeyOnly ( vertical , 'vertical' ) , useKeyOrValueAndKey ( attached , 'attached' ) , useValueAndKey ( stackable , 'stackable' ) , useWidthProp ( widths ) , 'steps' , className , ) const rest = getUnhandledProps ( StepGroup , props ) const ElementType = getElementType ( StepGroup , props ) if ( ! childrenUtils . isNil ( children ) ) { return ( < ElementType { ... rest } className = { classes } >
         { children }
       < / ElementType > ) } if ( ! childrenUtils . isNil ( content ) ) { return ( < ElementType { ... rest } className = { classes } >
         { content }
       < / ElementType > ) } return ( < ElementType { ... rest } className = { classes } >
       { _ . map ( items , item => Step . create ( item ) ) }
     < / ElementType > ) }


Input:
A divider visually segments content into groups . [CODESPLIT] function Divider ( props ) { const { children , className , clearing , content , fitted , hidden , horizontal , inverted , section , vertical , } = props const classes = cx ( 'ui' , useKeyOnly ( clearing , 'clearing' ) , useKeyOnly ( fitted , 'fitted' ) , useKeyOnly ( hidden , 'hidden' ) , useKeyOnly ( horizontal , 'horizontal' ) , useKeyOnly ( inverted , 'inverted' ) , useKeyOnly ( section , 'section' ) , useKeyOnly ( vertical , 'vertical' ) , 'divider' , className , ) const rest = getUnhandledProps ( Divider , props ) const ElementType = getElementType ( Divider , props ) return ( < ElementType { ... rest } className = { classes } >
       { childrenUtils . isNil ( children ) ? content : children }
     < / ElementType > ) }


Input:
A header provides a short summary of content [CODESPLIT] function Header ( props ) { const { attached , block , children , className , color , content , disabled , dividing , floated , icon , image , inverted , size , sub , subheader , textAlign , } = props const classes = cx ( 'ui' , color , size , useKeyOnly ( block , 'block' ) , useKeyOnly ( disabled , 'disabled' ) , useKeyOnly ( dividing , 'dividing' ) , useValueAndKey ( floated , 'floated' ) , useKeyOnly ( icon === true , 'icon' ) , useKeyOnly ( image === true , 'image' ) , useKeyOnly ( inverted , 'inverted' ) , useKeyOnly ( sub , 'sub' ) , useKeyOrValueAndKey ( attached , 'attached' ) , useTextAlignProp ( textAlign ) , 'header' , className , ) const rest = getUnhandledProps ( Header , props ) const ElementType = getElementType ( Header , props ) if ( ! childrenUtils . isNil ( children ) ) { return ( < ElementType { ... rest } className = { classes } >
         { children }
       < / ElementType > ) } const iconElement = Icon . create ( icon , { autoGenerateKey : false } ) const imageElement = Image . create ( image , { autoGenerateKey : false } ) const subheaderElement = HeaderSubheader . create ( subheader , { autoGenerateKey : false } ) if ( iconElement || imageElement ) { return ( < ElementType { ... rest } className = { classes } >
         { iconElement || imageElement }
         { ( content || subheaderElement ) && ( < HeaderContent >
             { content }
             { subheaderElement }
           < / HeaderContent > ) }
       < / ElementType > ) } return ( < ElementType { ... rest } className = { classes } >
       { content }
       { subheaderElement }
     < / ElementType > ) }


Input:
A grid is used to harmonize negative space in a layout . [CODESPLIT] function Grid ( props ) { const { celled , centered , children , className , columns , container , divided , doubling , inverted , padded , relaxed , reversed , stackable , stretched , textAlign , verticalAlign , } = props const classes = cx ( 'ui' , useKeyOnly ( centered , 'centered' ) , useKeyOnly ( container , 'container' ) , useKeyOnly ( doubling , 'doubling' ) , useKeyOnly ( inverted , 'inverted' ) , useKeyOnly ( stackable , 'stackable' ) , useKeyOnly ( stretched , 'stretched' ) , useKeyOrValueAndKey ( celled , 'celled' ) , useKeyOrValueAndKey ( divided , 'divided' ) , useKeyOrValueAndKey ( padded , 'padded' ) , useKeyOrValueAndKey ( relaxed , 'relaxed' ) , useMultipleProp ( reversed , 'reversed' ) , useTextAlignProp ( textAlign ) , useVerticalAlignProp ( verticalAlign ) , useWidthProp ( columns , 'column' , true ) , 'grid' , className , ) const rest = getUnhandledProps ( Grid , props ) const ElementType = getElementType ( Grid , props ) return ( < ElementType { ... rest } className = { classes } >
       { children }
     < / ElementType > ) }


Input:
A breadcrumb is used to show hierarchy between content . [CODESPLIT] function Breadcrumb ( props ) { const { children , className , divider , icon , sections , size } = props const classes = cx ( 'ui' , size , 'breadcrumb' , className ) const rest = getUnhandledProps ( Breadcrumb , props ) const ElementType = getElementType ( Breadcrumb , props ) if ( ! childrenUtils . isNil ( children ) ) { return ( < ElementType { ... rest } className = { classes } >
         { children }
       < / ElementType > ) } const childElements = [ ] _ . each ( sections , ( section , index ) => { // section const breadcrumbElement = BreadcrumbSection . create ( section ) childElements . push ( breadcrumbElement ) // divider if ( index !== sections . length - 1 ) { const key = ` ${ breadcrumbElement . key } ` || JSON . stringify ( section ) childElements . push ( BreadcrumbDivider . create ( { content : divider , icon , key } ) ) } } ) return ( < ElementType { ... rest } className = { classes } >
       { childElements }
     < / ElementType > ) }


Input: Sugar for <Form . Field control = { Dropdown } / > . [CODESPLIT] function FormDropdown ( props ) { const { control } = props const rest = getUnhandledProps ( FormDropdown , props ) const ElementType = getElementType ( FormDropdown , props ) return < ElementType { ... rest } control = { control } / > }


Input:
A card can contain a description with one or more paragraphs . [CODESPLIT] function CardDescription ( props ) { const { children , className , content , textAlign } = props const classes = cx ( useTextAlignProp ( textAlign ) , 'description' , className ) const rest = getUnhandledProps ( CardDescription , props ) const ElementType = getElementType ( CardDescription , props ) return ( < ElementType { ... rest } className = { classes } >
       { childrenUtils . isNil ( children ) ? content : children }
     < / ElementType > ) }


Input:
A group of items . [CODESPLIT] function ItemGroup ( props ) { const { children , className , content , divided , items , link , relaxed , unstackable } = props const classes = cx ( 'ui' , useKeyOnly ( divided , 'divided' ) , useKeyOnly ( link , 'link' ) , useKeyOnly ( unstackable , 'unstackable' ) , useKeyOrValueAndKey ( relaxed , 'relaxed' ) , 'items' , className , ) const rest = getUnhandledProps ( ItemGroup , props ) const ElementType = getElementType ( ItemGroup , props ) if ( ! childrenUtils . isNil ( children ) ) { return ( < ElementType { ... rest } className = { classes } >
         { children }
       < / ElementType > ) } if ( ! childrenUtils . isNil ( content ) ) { return ( < ElementType { ... rest } className = { classes } >
         { content }
       < / ElementType > ) } const itemsJSX = _ . map ( items , ( item ) => { const { childKey , ... itemProps } = item const finalKey = childKey || [ itemProps . content , itemProps . description , itemProps . header , itemProps . meta ] . join ( '-' ) return < Item { ... itemProps } key = { finalKey } / > } ) return ( < ElementType { ... rest } className = { classes } >
       { itemsJSX }
     < / ElementType > ) }


Input:
A column sub - component for Grid . [CODESPLIT] function GridColumn ( props ) { const { children , className , computer , color , floated , largeScreen , mobile , only , stretched , tablet , textAlign , verticalAlign , widescreen , width , } = props const classes = cx ( color , useKeyOnly ( stretched , 'stretched' ) , useMultipleProp ( only , 'only' ) , useTextAlignProp ( textAlign ) , useValueAndKey ( floated , 'floated' ) , useVerticalAlignProp ( verticalAlign ) , useWidthProp ( computer , 'wide computer' ) , useWidthProp ( largeScreen , 'wide large screen' ) , useWidthProp ( mobile , 'wide mobile' ) , useWidthProp ( tablet , 'wide tablet' ) , useWidthProp ( widescreen , 'wide widescreen' ) , useWidthProp ( width , 'wide' ) , 'column' , className , ) const rest = getUnhandledProps ( GridColumn , props ) const ElementType = getElementType ( GridColumn , props ) return ( < ElementType { ... rest } className = { classes } >
       { children }
     < / ElementType > ) }


Input: An item can contain an image . [CODESPLIT] function ItemImage ( props ) { const { size } = props const rest = getUnhandledProps ( ItemImage , props ) return < Image { ... rest } size = { size } ui = { ! ! size } wrapped / > }


Input:
A group of cards . [CODESPLIT] function CardGroup ( props ) { const { centered , children , className , content , doubling , items , itemsPerRow , stackable , textAlign , } = props const classes = cx ( 'ui' , useKeyOnly ( centered , 'centered' ) , useKeyOnly ( doubling , 'doubling' ) , useKeyOnly ( stackable , 'stackable' ) , useTextAlignProp ( textAlign ) , useWidthProp ( itemsPerRow ) , 'cards' , className , ) const rest = getUnhandledProps ( CardGroup , props ) const ElementType = getElementType ( CardGroup , props ) if ( ! childrenUtils . isNil ( children ) ) { return ( < ElementType { ... rest } className = { classes } >
         { children }
       < / ElementType > ) } if ( ! childrenUtils . isNil ( content ) ) { return ( < ElementType { ... rest } className = { classes } >
         { content }
       < / ElementType > ) } const itemsJSX = _ . map ( items , ( item ) => { const key = item . key || [ item . header , item . description ] . join ( '-' ) return < Card key = { key } { ... item } / > } ) return ( < ElementType { ... rest } className = { classes } >
       { itemsJSX }
     < / ElementType > ) }


Input:
A table can have rows . [CODESPLIT] function TableRow ( props ) { const { active , cellAs , cells , children , className , disabled , error , negative , positive , textAlign , verticalAlign , warning , } = props const classes = cx ( useKeyOnly ( active , 'active' ) , useKeyOnly ( disabled , 'disabled' ) , useKeyOnly ( error , 'error' ) , useKeyOnly ( negative , 'negative' ) , useKeyOnly ( positive , 'positive' ) , useKeyOnly ( warning , 'warning' ) , useTextAlignProp ( textAlign ) , useVerticalAlignProp ( verticalAlign ) , className , ) const rest = getUnhandledProps ( TableRow , props ) const ElementType = getElementType ( TableRow , props ) if ( ! childrenUtils . isNil ( children ) ) { return ( < ElementType { ... rest } className = { classes } >
         { children }
       < / ElementType > ) } return ( < ElementType { ... rest } className = { classes } >
       { _ . map ( cells , cell => TableCell . create ( cell , { defaultProps : { as : cellAs } } ) ) }
     < / ElementType > ) }


Input: Sugar for <Form . Field control = { Button } / > . [CODESPLIT] function FormButton ( props ) { const { control } = props const rest = getUnhandledProps ( FormButton , props ) const ElementType = getElementType ( FormButton , props ) return < ElementType { ... rest } control = { control } / > }


Input: This component exposes a prop that supports functional and createRef () API and returns the DOM node of both functional and class component children . [CODESPLIT] function Ref ( props ) { const { children , innerRef } = props const child = React . Children . only ( children ) const ElementType = isForwardRef ( child ) ? RefForward : RefFindNode return < ElementType innerRef = { innerRef } > { child } < / ElementType > }


Input:
A feed contains an event . [CODESPLIT] function FeedEvent ( props ) { const { content , children , className , date , extraImages , extraText , image , icon , meta , summary , } = props const classes = cx ( 'event' , className ) const rest = getUnhandledProps ( FeedEvent , props ) const ElementType = getElementType ( FeedEvent , props ) const hasContentProp = content || date || extraImages || extraText || meta || summary const contentProps = { content , date , extraImages , extraText , meta , summary } return ( < ElementType { ... rest } className = { classes } >
       { createShorthand ( FeedLabel , val => ( { icon : val } ) , icon , { autoGenerateKey : false } ) }
       { createShorthand ( FeedLabel , val => ( { image : val } ) , image , { autoGenerateKey : false } ) }
       { hasContentProp && < FeedContent { ... contentProps } / > }
       { children }
     < / ElementType > ) }


Input:
A tab pane holds the content of a tab . [CODESPLIT] function TabPane ( props ) { const { active , children , className , content , loading } = props const classes = cx ( useKeyOnly ( active , 'active' ) , useKeyOnly ( loading , 'loading' ) , 'tab' , className ) const rest = getUnhandledProps ( TabPane , props ) const ElementType = getElementType ( TabPane , props ) const calculatedDefaultProps = { } if ( ElementType === Segment ) { calculatedDefaultProps . attached = 'bottom' } return ( < ElementType { ... calculatedDefaultProps } { ... rest } className = { classes } >
       { childrenUtils . isNil ( children ) ? content : children }
     < / ElementType > ) }


Input:
A list item can contain a content . [CODESPLIT] function ListContent ( props ) { const { children , className , content , description , floated , header , verticalAlign } = props const classes = cx ( useValueAndKey ( floated , 'floated' ) , useVerticalAlignProp ( verticalAlign ) , 'content' , className , ) const rest = getUnhandledProps ( ListContent , props ) const ElementType = getElementType ( ListContent , props ) if ( ! childrenUtils . isNil ( children ) ) { return ( < ElementType { ... rest } className = { classes } >
         { children }
       < / ElementType > ) } return ( < ElementType { ... rest } className = { classes } >
       { ListHeader . create ( header ) }
       { ListDescription . create ( description ) }
       { content }
     < / ElementType > ) }


Input: Button groups can contain conditionals . [CODESPLIT] function ButtonOr ( props ) { const { className , text } = props const classes = cx ( 'or' , className ) const rest = getUnhandledProps ( ButtonOr , props ) const ElementType = getElementType ( ButtonOr , props ) return < ElementType { ... rest } className = { classes } data-text = { text } / > }


Input:
A table row can have cells . [CODESPLIT] function TableCell ( props ) { const { active , children , className , collapsing , content , disabled , error , icon , negative , positive , selectable , singleLine , textAlign , verticalAlign , warning , width , } = props const classes = cx ( useKeyOnly ( active , 'active' ) , useKeyOnly ( collapsing , 'collapsing' ) , useKeyOnly ( disabled , 'disabled' ) , useKeyOnly ( error , 'error' ) , useKeyOnly ( negative , 'negative' ) , useKeyOnly ( positive , 'positive' ) , useKeyOnly ( selectable , 'selectable' ) , useKeyOnly ( singleLine , 'single line' ) , useKeyOnly ( warning , 'warning' ) , useTextAlignProp ( textAlign ) , useVerticalAlignProp ( verticalAlign ) , useWidthProp ( width , 'wide' ) , className , ) const rest = getUnhandledProps ( TableCell , props ) const ElementType = getElementType ( TableCell , props ) if ( ! childrenUtils . isNil ( children ) ) { return ( < ElementType { ... rest } className = { classes } >
         { children }
       < / ElementType > ) } return ( < ElementType { ... rest } className = { classes } >
       { Icon . create ( icon ) }
       { content }
     < / ElementType > ) }


Input:
A divider sub - component for Breadcrumb component . [CODESPLIT] function BreadcrumbDivider ( props ) { const { children , className , content , icon } = props const classes = cx ( 'divider' , className ) const rest = getUnhandledProps ( BreadcrumbDivider , props ) const ElementType = getElementType ( BreadcrumbDivider , props ) if ( ! _ . isNil ( icon ) ) { return Icon . create ( icon , { defaultProps : { ... rest , className : classes } , autoGenerateKey : false , } ) } if ( ! _ . isNil ( content ) ) { return ( < ElementType { ... rest } className = { classes } >
         { content }
       < / ElementType > ) } return ( < ElementType { ... rest } className = { classes } >
       { childrenUtils . isNil ( children ) ? '/' : children }
     < / ElementType > ) }


Input:
A message can contain a list of items . [CODESPLIT] function MessageList ( props ) { const { children , className , items } = props const classes = cx ( 'list' , className ) const rest = getUnhandledProps ( MessageList , props ) const ElementType = getElementType ( MessageList , props ) return ( < ElementType { ... rest } className = { classes } >
       { childrenUtils . isNil ( children ) ? _ . map ( items , MessageItem . create ) : children }
     < / ElementType > ) }


Input: A table can have a footer . [CODESPLIT] function TableFooter ( props ) { const { as } = props const rest = getUnhandledProps ( TableFooter , props ) return < TableHeader { ... rest } as = { as } / > }


Input:
Comments can be grouped . [CODESPLIT] function CommentGroup ( props ) { const { className , children , collapsed , content , minimal , size , threaded } = props const classes = cx ( 'ui' , size , useKeyOnly ( collapsed , 'collapsed' ) , useKeyOnly ( minimal , 'minimal' ) , useKeyOnly ( threaded , 'threaded' ) , 'comments' , className , ) const rest = getUnhandledProps ( CommentGroup , props ) const ElementType = getElementType ( CommentGroup , props ) return ( < ElementType { ... rest } className = { classes } >
       { childrenUtils . isNil ( children ) ? content : children }
     < / ElementType > ) }


Input:
A reveal displays additional content in place of previous content when activated . [CODESPLIT] function Reveal ( props ) { const { active , animated , children , className , content , disabled , instant } = props const classes = cx ( 'ui' , animated , useKeyOnly ( active , 'active' ) , useKeyOnly ( disabled , 'disabled' ) , useKeyOnly ( instant , 'instant' ) , 'reveal' , className , ) const rest = getUnhandledProps ( Reveal , props ) const ElementType = getElementType ( Reveal , props ) return ( < ElementType { ... rest } className = { classes } >
       { childrenUtils . isNil ( children ) ? content : children }
     < / ElementType > ) }


Input:
A segment is used to create a grouping of related content . [CODESPLIT] function Segment ( props ) { const { attached , basic , children , circular , className , clearing , color , compact , content , disabled , floated , inverted , loading , placeholder , padded , piled , raised , secondary , size , stacked , tertiary , textAlign , vertical , } = props const classes = cx ( 'ui' , color , size , useKeyOnly ( basic , 'basic' ) , useKeyOnly ( circular , 'circular' ) , useKeyOnly ( clearing , 'clearing' ) , useKeyOnly ( compact , 'compact' ) , useKeyOnly ( disabled , 'disabled' ) , useKeyOnly ( inverted , 'inverted' ) , useKeyOnly ( loading , 'loading' ) , useKeyOnly ( placeholder , 'placeholder' ) , useKeyOnly ( piled , 'piled' ) , useKeyOnly ( raised , 'raised' ) , useKeyOnly ( secondary , 'secondary' ) , useKeyOnly ( stacked , 'stacked' ) , useKeyOnly ( tertiary , 'tertiary' ) , useKeyOnly ( vertical , 'vertical' ) , useKeyOrValueAndKey ( attached , 'attached' ) , useKeyOrValueAndKey ( padded , 'padded' ) , useTextAlignProp ( textAlign ) , useValueAndKey ( floated , 'floated' ) , 'segment' , className , ) const rest = getUnhandledProps ( Segment , props ) const ElementType = getElementType ( Segment , props ) return ( < ElementType { ... rest } className = { classes } >
       { childrenUtils . isNil ( children ) ? content : children }
     < / ElementType > ) }


Input: Sugar for <Form . Field control = { Input } / > . [CODESPLIT] function FormInput ( props ) { const { control } = props const rest = getUnhandledProps ( FormInput , props ) const ElementType = getElementType ( FormInput , props ) return < ElementType { ... rest } control = { control } / > }


Input: A placeholder can contain have lines of text . [CODESPLIT] function PlaceholderLine ( props ) { const { className , length } = props const classes = cx ( 'line' , length , className ) const rest = getUnhandledProps ( PlaceholderLine , props ) const ElementType = getElementType ( PlaceholderLine , props ) return < ElementType { ... rest } className = { classes } / > }


Input:
A content sub - component for the Reveal . [CODESPLIT] function RevealContent ( props ) { const { children , className , content , hidden , visible } = props const classes = cx ( 'ui' , useKeyOnly ( hidden , 'hidden' ) , useKeyOnly ( visible , 'visible' ) , 'content' , className , ) const rest = getUnhandledProps ( RevealContent , props ) const ElementType = getElementType ( RevealContent , props ) return ( < ElementType { ... rest } className = { classes } >
       { childrenUtils . isNil ( children ) ? content : children }
     < / ElementType > ) }


Input:
A feed can contain a like element . [CODESPLIT] function FeedLike ( props ) { const { children , className , content , icon } = props const classes = cx ( 'like' , className ) const rest = getUnhandledProps ( FeedLike , props ) const ElementType = getElementType ( FeedLike , props ) if ( ! childrenUtils . isNil ( children ) ) { return ( < ElementType { ... rest } className = { classes } >
         { children }
       < / ElementType > ) } return ( < ElementType { ... rest } className = { classes } >
       { Icon . create ( icon , { autoGenerateKey : false } ) }
       { content }
     < / ElementType > ) }


Input:
A placeholder is used to reserve splace for content that soon will appear in a layout . [CODESPLIT] function Placeholder ( props ) { const { children , className , content , fluid , inverted } = props const classes = cx ( 'ui' , useKeyOnly ( fluid , 'fluid' ) , useKeyOnly ( inverted , 'inverted' ) , 'placeholder' , className , ) const rest = getUnhandledProps ( Placeholder , props ) const ElementType = getElementType ( Placeholder , props ) return ( < ElementType { ... rest } className = { classes } >
       { childrenUtils . isNil ( children ) ? content : children }
     < / ElementType > ) }


Input: An accordion allows users to toggle the display of sections of content . [CODESPLIT] function Accordion ( props ) { const { className , fluid , inverted , styled } = props const classes = cx ( 'ui' , useKeyOnly ( fluid , 'fluid' ) , useKeyOnly ( inverted , 'inverted' ) , useKeyOnly ( styled , 'styled' ) , className , ) const rest = getUnhandledProps ( Accordion , props ) return < AccordionAccordion { ... rest } className = { classes } / > }


Input: A placeholder can contain an image . [CODESPLIT] function PlaceholderImage ( props ) { const { className , square , rectangular } = props const classes = cx ( useKeyOnly ( square , 'square' ) , useKeyOnly ( rectangular , 'rectangular' ) , 'image' , className , ) const rest = getUnhandledProps ( PlaceholderImage , props ) const ElementType = getElementType ( PlaceholderImage , props ) return < ElementType { ... rest } className = { classes } / > }


Input:
A dropdown menu can contain a menu . [CODESPLIT] function DropdownMenu ( props ) { const { children , className , content , direction , open , scrolling } = props const classes = cx ( direction , useKeyOnly ( open , 'visible' ) , useKeyOnly ( scrolling , 'scrolling' ) , 'menu transition' , className , ) const rest = getUnhandledProps ( DropdownMenu , props ) const ElementType = getElementType ( DropdownMenu , props ) return ( < ElementType { ... rest } className = { classes } >
       { childrenUtils . isNil ( children ) ? content : children }
     < / ElementType > ) }


Input: A list item can contain an icon . [CODESPLIT] function ListIcon ( props ) { const { className , verticalAlign } = props const classes = cx ( useVerticalAlignProp ( verticalAlign ) , className ) const rest = getUnhandledProps ( ListIcon , props ) return < Icon { ... rest } className = { classes } / > }


Input:
An ad displays third - party promotional content . [CODESPLIT] function Advertisement ( props ) { const { centered , children , className , content , test , unit } = props const classes = cx ( 'ui' , unit , useKeyOnly ( centered , 'centered' ) , useKeyOnly ( test , 'test' ) , 'ad' , className , ) const rest = getUnhandledProps ( Advertisement , props ) const ElementType = getElementType ( Advertisement , props ) return ( < ElementType { ... rest } className = { classes } data-text = { test } >
       { childrenUtils . isNil ( children ) ? content : children }
     < / ElementType > ) }


Input:
A group of statistics . [CODESPLIT] function StatisticGroup ( props ) { const { children , className , color , content , horizontal , inverted , items , size , widths } = props const classes = cx ( 'ui' , color , size , useKeyOnly ( horizontal , 'horizontal' ) , useKeyOnly ( inverted , 'inverted' ) , useWidthProp ( widths ) , 'statistics' , className , ) const rest = getUnhandledProps ( StatisticGroup , props ) const ElementType = getElementType ( StatisticGroup , props ) if ( ! childrenUtils . isNil ( children ) ) { return ( < ElementType { ... rest } className = { classes } >
         { children }
       < / ElementType > ) } if ( ! childrenUtils . isNil ( content ) ) { return ( < ElementType { ... rest } className = { classes } >
         { content }
       < / ElementType > ) } return ( < ElementType { ... rest } className = { classes } >
       { _ . map ( items , item => Statistic . create ( item ) ) }
     < / ElementType > ) }