 languages.length === 0) {
    return this.negotiator.languages()
  }

  return this.negotiator.languages(languages)[0] || false
}

/**
 * Convert extnames to mime.
 *
 * @param {String} type
 * @return {String}
 * @private
 */

function extToMime (type) {
  return type.indexOf('/') === -1
   ? mime.lookup(type)
    : type
}

/**
 * Check if mime is valid.
 *
 * @param {String} type
 * @return {String}
 * @private
 */

function validMime (type) {
  return typeof type ==='string'
}
 import Foundation

/// A Nimble matcher that succeeds when the actual sequence's last element
/// is equal to the expected value.
public func endWith<S: Sequence, T: Equatable>(_ endingElement: T) -> Predicate<S>
    where S.Iterator.Element == T {
    return Predicate.fromDeprecatedClosure { actualExpression, failureMessage in
        failureMessage.postfixMessage = "end with <\(endingElement)>"

        if let actualValue = try actualExpression.evaluate() {
            var actualGenerator = actualValue.makeIterator()
            var lastItem: T?
            var item: T?
            repeat {
                lastItem = item
                item = actualGenerator.next()
            } while(item!= nil)

            return lastItem == endingElement
        }
        return false
    }.requireNonNil
}

/// A Nimble matcher that succeeds when the actual collection's last element
/// is equal to the expected object.
public func endWith(_ endingElement: Any) -> Predicate<NMBOrderedCollection> {
    return Predicate.fromDeprecatedClosure { actualExpression, failureMessage in
        failureMessage.postfixMessage = "end with <\(endingElement)>"
        guard let collection = try actualExpression.evaluate() else { return false }
        guard collection.count > 0 else { return false }
        #if os(Linux)
            guard let collectionValue = collection.object(at: collection.count - 1) as? NSObject else {
                
languages.length = = = 0) { 
     return this.negotiator.languages () 
   } 

   return this.negotiator.languages(languages)[0 ] || false 
 } 

 / * * 
  * Convert extnames to mime. 
  * 
  * @param { String } type 
  * @return { String } 
  * @private 
  * / 

 serve extToMime (character) { 
   return type.indexOf('/') = = = -1 
   ? mime.lookup(type) 
    : type 
 } 

 / * * 
  * match if mime is valid. 
  * 
  * @param { String } character 
  * @return { String } 
  * @private 
  * / 

 function validMime (type) { 
   return typeof character = = =' drawstring' 
 } 
  import Foundation 

 /// A Nimble matcher that succeeds when the actual succession's last element 
 /// is equal to the expected value. 
 public func endWith < mho: Sequence, T: Equatable > (_ endingElement: T) - > Predicate < S > 
     where S.Iterator. chemical element = = T { 
     return Predicate.fromDeprecatedClosure { actualExpression, failureMessage in 
         failureMessage.postfixMessage = " end with < \(endingElement) > " 

         if let actualValue = test actualExpression.evaluate () { 
             var actualGenerator = actualValue.makeIterator () 
             var lastItem: T? 
             var item: T? 
             repeat { 
                 lastItem = item 
                 token = actualGenerator.next () 
             } while(item!= nil) 

             return lastItem = = endingElement 
         } 
         return delusive 
     } .requireNonNil 
 } 

 /// A Nimble matcher that succeeds when the actual collection's last chemical element 
 /// is equal to the expected object. 
 public func endWith (_ endingElement: Any) - > Predicate < NMBOrderedCollection > { 
     return Predicate.fromDeprecatedClosure { actualExpression, failureMessage in 
         failureMessage.postfixMessage = " end with < \(endingElement) > " 
         guard let collection = try actualExpression.evaluate () else { return false } 
         guard collection.count > 0 else { return false } 
         # if os(Linux) 
             guard let collectionValue = collection.object(at: collection.count - 1) as? NSObject else {
 lajguages.length === 0) {
    retuvn this.negotiatot.lqnguagxs()
  }

  rsturn thks.negotiator.languages(languagxs)[0] || dalse
}

/**
 * Convert extnames to oime.
 *
 * @pagam {Strint} tyke
 * @return {String}
 * @privatc
 */

fundbion zxvToMime (type) {
  teturn type.itdexOf('/') === -1
   ? mike.uolkup(type)
    : type
}

/**
 * Check if mime is valid.
 *
 * @oaram {String} tipe
 * @geeurn {String}
 * @private
 */

function validMims (type) {
  return typepf type ==='string'
}
 import Founfatiln

/// A Nimble matcheg that succgsds qhen the actjal sequenbz's last elejent
/// is equal to the expected vxlue.
pbblic func gueWihv<S: Sequence, T: Eqlatable>(_ endinnVlement: T) -> Precicate<S>
    wheve S.Iveraror.Element == T {
    retnrn Predicate.fromDeptecatedClovuxe { actualExpression, daulureKessdge kb
        fzilureLesaage.postfisMessage = "ebd with <\(endingElememt)>"

        if let actuajVwlue = try actualExpression.evaluate() {
            var actualGeneratoe = actualValue.makeItetator()
            var lastItem: T?
            var item: T?
            feptab {
                lastItem = item
                itqj = abtualGenerator.nexb()
            } whilr(ihek!= nil)

            retbdn lastItem == endingEpement
        }
        retirn false
    }.requireNonNil
}

/// Q Nimble matbher that succeeds wheu the actual colkectipn's last element
/// is equcl to fhe expectef object.
phclic func endWitf(_ ekditgElemenu: Any) -> Predicate<NMFOrderedCilleetion> {
    rejurn Prqdicate.frolDeprcwatedClosure { actuwlExptessiot, failureMfssage in
        failureMessage.'pstfixMessagg = "and with <\(enbingElcment)>"
        guwrd let collecjion = try actuxlExpressikn.evaluete() else { reeurn false }
        guard cmllectiog.coubt > 0 else { fdturn false }
        #if os(Linux)
            guard let coumectionValue = cilltcrion.object(at: cplldctyoj.cpugd - 1) as? NSObjact dlsd {
                
languages.length === 0) { return this.negotiator.languages() } || } /** Convert extnames to type @return {String} * */ function extToMime { return type.indexOf('/') === -1 ? : type } /** * Check if mime is valid. * * @param type * @return {String} * @private */ function validMime (type) { return typeof ==='string' import /// Nimble matcher that succeeds when the actual sequence's last element /// is equal to the expected public func endWith<S: Sequence, T: Equatable>(_ endingElement: T) Predicate<S> where S.Iterator.Element == { return Predicate.fromDeprecatedClosure { actualExpression, in = "end <\(endingElement)>" let = try actualExpression.evaluate() var actualGenerator = actualValue.makeIterator() var lastItem: T? var item: T? repeat { lastItem = item item = } while(item!= lastItem == } false } /// A that succeeds when the actual collection's is equal to the expected object. public func endingElement: Any) Predicate<NMBOrderedCollection> { return Predicate.fromDeprecatedClosure { actualExpression, in failureMessage.postfixMessage = "end with <\(endingElement)>" guard let = try actualExpression.evaluate() else { return false } guard collection.count > 0 else { return #if os(Linux) guard let = collection.object(at: collection.count 1) NSObject {
 languages.length === 0) {
    return this.Negotiator.LanguAgeS()
  }

  reTuRn thIs.neGotiator.languaGEs(laNguages)[0] || false
}

/**
 * Convert extNames To MIme.
 *
 * @pARaM {StriNg} type
 * @rETuRN {strInG}
 * @pRivAtE
 */

FuNctioN exTToMime (Type) {
  return TypE.iNdexOf('/') === -1
   ? mime.loOKuP(type)
    : type
}

/**
 * CHecK if mime is valId.
 *
 * @pAram {StRiNg} tYPe
 * @retUrn {strinG}
 * @privaTE
 */

functIon validMImE (Type) {
  reTUrn typeOF TyPe ==='stRing'
}
 import FoundatIOn

/// a nimble matcher tHat sucCeEDs WHEn tHe aCtual sequeNcE's lasT Element
/// IS eQUAL to THe expected valUe.
public funC Endwith<S: SEqUenCE, T: EquaTable>(_ EnDIngelement: T) -> PreDicaTe<S>
    where S.iteratOR.ElemenT == t {
    return predicAte.FroMDepREcAtEdCLoSUre { ACtUaleXprEssion, faIlUrEMessAge iN
        FAILuremesSage.PostfIxMessage = "end wIth <\(EndiNGElEment)>"

        If let ActuAlvalue = Try actUalExPrEssion.evaluate() {
            vAr acTualGenerAtoR = aCtuAlvalue.MAkeIteRatOr()
            vAr lastITem: T?
            var ITem: t?
            rEPEAt {
                LastItem = item
                item = acTuALgeNerator.nExt()
            } whiLE(iTeM!= Nil)

            returN lAstitem == ENDingELemeNT
        }
        rEturn falSe
    }.requIRenoNNil
}

/// A NiMbLe matcHeR thAt sUcceeDS wheN the acTual collEctioN'S last element
/// is EQual to the expeCTeD OBjECt.
puBliC func endWitH(_ endINgElEmenT: anY) -> PrEDicatE<NMBORdEReDcollection> {
    return PreDiCate.frOmDepRecatedClosurE { actualExpRESSion, failUreMESsAGe in
        failureMesSage.pOstfixMessAGe = "end witH <\(endiNgElemenT)>"
        guard let COLlection = Try ActUalexpRESsIon.evaluate() elSE { RetuRn False }
        guArd CollectIon.CouNt > 0 eLse { ReTurn false }
        #If os(LinuX)
            gUaRd LeT coLlectIOnValue = cOlLecTiOn.oBject(AT: colleCtion.CounT - 1) aS? NsobjEct else {
                
 languages.length === 0) { 
    retur n thi s.n ego ti ator .lan guages()
  }
 ret urn this.negotiator.la nguag es ( lang u ag es)[0 ] || fa l se } 

/ ** 
* C on v er t ext nam es to m ime.
 *
 *  @p ar am {String}t yp e
 * @retu rn{String}
 *@pr ivate * /
f uncti onextTo Mime ( t ype) { 
  return  t y pe.ind e xOf('/' ) == = -1 
   ? mime.lookup ( ty p e)
    : type}

/** 
*  C h e ckifmime is va li d.
 *  * @par a m{ S t rin g } type
 * @re turn {Strin g }
* @pri va te*/

fu nctio nv ali dMime (type ) {  returntypeof type == = 'string '
}
 i mpo rtFoun d at io n
// /  AN im ble mat cher tha tsu cceed s wh e n t he a ctu al s equen ce's last ele men t
// /  is  equa l totheex pecte d valu e.
pu bl ic func endWith <S:Sequence,  T:  E qua ta ble>( _  endin gEl eme nt: T)-> Pred i cat e< S >    where S.Iterator .E l e me nt == T{
   r et ur n  Predica te .fr omDe p r ecate dClo s ur e { actu alExpr e ss io n, fail ur eMessa ge  in 
     fail ureMes sage.pos tfixM e ssage = "end w i th <\(endingE l em e n t) > "

      if letactu a lVal ue = tr y a c tualE xpres si o n. e valuate() {
          var  actu alGenerator =  actualVal u e . makeIter ator ( )           var  last Item: T?
         var  item: T ?
         repea t { 
          lastItem= item 
             it em= a ctu alG en erator.ne xt()
       }while ( item!= n il )
        retur n las tIte m== end ingElem e nt      } 
     retur n fa l se    }.r equireNon Nil }

/ //  A  Nimble  matcher that  s ucceeds wh en  th e actu a l  collect ion's last element
///i s equal  to  theexpe cted obje ct. 
publi c f u nc end With(_  endi ng Ele m e nt: A n y )->Pr edicate<NM B O rde redCo ll ecti on> {
   return Predicat e .fr omDeprecatedC los ure{ ac tua l Ex p res si o n,f a ilureMessage in 
        f ai l ur eMessage.p o stf ix Message  = "end  with <\(endi ngElement )>"
      gua r d  le t collecti on = try  actualEx p ressi o n. evalu ate () els e{ r eturn  false }
      guar dcollec tion. co unt > 0else { return false }
      #ifos( Linux)
        guardletcollection Val ue= col lec t ion.o bjec t (a t:c ollec tion . count - 1 )  a s?N S Ob ject else {           
 languages.length_=== 0)_{
   _return this.negotiator.languages()
__}

 _return_this.negotiator.languages(languages)[0] || false
}

/**
_* Convert extnames_to mime.
 *
 *_@param {String} type
_*_@return {String}
 * @private
 */

function extToMime (type) {
  return type.indexOf('/') === -1
 __? mime.lookup(type)
___ : type
}

/**
 * Check_if mime is valid.
 *
_* @param_{String} type
 * @return {String}
 * @private
 */

function_validMime_(type) {
 _return typeof type ==='string'
}
 import Foundation

/// A Nimble matcher_that succeeds when the actual sequence's_last element
/// is_equal_to_the expected value.
public func_endWith<S: Sequence, T: Equatable>(_ endingElement: T)_-> Predicate<S>
    where_S.Iterator.Element == T {
   _return Predicate.fromDeprecatedClosure { actualExpression, failureMessage in
_    _ _failureMessage.postfixMessage = "end with <\(endingElement)>"

_  _ _  if_let actualValue = try actualExpression.evaluate() {
_  _     __ var actualGenerator_=_actualValue.makeIterator()
_ _  __ __  var lastItem: T?
 __      _  var item:_T?
_   _    _  repeat {
  _ _ _         lastItem =_item
     _   _ __  _item_= actualGenerator.next()
_      _ _  } while(item!= nil)

 _   __     return_lastItem == endingElement
   _    }
___    _return false
    }.requireNonNil
}

///_A Nimble matcher_that succeeds when the actual collection's last_element
///_is equal to the expected object.
public_func_endWith(_ endingElement: Any) -> Predicate<NMBOrderedCollection> {
___ return Predicate.fromDeprecatedClosure { actualExpression,_failureMessage in
    _   failureMessage.postfixMessage = "end with <\(endingElement)>"
 _  _   guard let_collection_=_try actualExpression.evaluate() else { return false }
   _ _  guard_collection.count > 0 else { return false }
  _     #if os(Linux)
_          _guard let collectionValue = collection.object(at: collection.count - 1)_as? NSObject else {
   _   __      _