Code Monkey home page Code Monkey logo

grep.js's Introduction

##Grep.js

Best used when saved as a snippet. To do so in Chrome Dev Tools, read here

This is a basic function which allows you to search through an object's properties and find a property based on a match. This is particularly useful when searching for a given DOM API and if you are unsure if it is vendor prefixed.

###Overview Basic function that searches / filters any object or function and returns matched properties.

This receives either a string or regex as the initial parameter( strSearch ), the sencond parameter ( isRecursive == Bool ) is used to determine whether to search the property's properties should the current property be of type object / function.

Main area of use would be for DevTools purposes, when needing to find a specific property but only part of the property name is known. Is now an inherited method on any Object / Function due to Object.prototype.

This method returns an object of all matches and their relative properties. Should not match be found, each property of the given object that is an object itself will be checked for any matches.

###Usage

Object.Grep( 'SearchTerm' ). * in browser console

eg:

 navigator.Grep( 'geo' ); 
 // returns an object of matched results and their relative properties

For usage in node you will need to use require:

Object = require( 'grep' );

Should you wish to use this with an interface as opposed to having to use the console, http://object.hasownproperty.com can be used.

Based on original grep.js gist

Contributing

Please run grunt tasks before submitting a pull request and adhere to the existing style.

License

Copyright (c) 2014 Nic da Costa
Licensed under the MIT License

grep.js's People

Contributors

divanvisagie avatar nicdacosta avatar

Stargazers

Neos21 avatar Daniel Bayley avatar Michael Anthony avatar  avatar

Watchers

James Cloos avatar  avatar Michael Anthony avatar

grep.js's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.