New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

firstkey

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

firstkey

Returns the first key found on an object from a list of keys

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

firstKey Build Status

Returns the first key found on an object from a list of keys

Example

    var obj = {
        word1: 'The',
        word2: 'quick',
        word5: 'jumped',
        word8: 'lazy'
    },
    
    key = firstKey(obj, 'word3', 'word5', 'word7');  // First key found is 'word5'

Pull the first property from a dom node that exists and reuse that property

  • Choosing the text property to use

     var div = document.createElement('div'),
         text = firstKey(div, 'textContent', 'innerText', 'innerHTML');
         
     div[text] = 'Let\'s use the best property for setting the text';
    
  • Identifying the vendor-specific property to use, so that you don't set them all needlessly

     var divElement = document.createElement('div'),
     
     transformProperty = firstKey(
         divElement.style,
         'transform',
         'webkitTransform',
         'MozTransform',
         'oTransform',
         'msTransform');
    
     transformOriginProperty = firstKey(
         divElement.style,
         'transformOrigin',
         'webkitTransformOrigin',
         'MozTransformOrigin',
         'oTransformOrigin',
         'msTransformOrigin');
    

Installation

npm install firstkey

Contributors

  • Matt-Esch

MIT Licenced

FAQs

Package last updated on 11 Dec 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts