Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@moxb/react-html

Package Overview
Dependencies
Maintainers
4
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@moxb/react-html - npm Package Compare versions

Comparing version 0.3.78 to 0.3.79

5

dist/highlighter/highlighter.d.ts
import * as React from 'react';
import type { NormalizerOptions } from '@moxb/moxb';
export interface HighlightOptions {
/**
* Options for identifying the matches
*/
findOptions?: NormalizerOptions;
/**
* Which class to use for highlighting?

@@ -5,0 +10,0 @@ *

28

dist/highlighter/highlighter.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.highlightSearchResult = void 0;
var moxb_1 = require("@moxb/moxb");
var util_1 = require("../util");
/**
* Identify pattern matches within a corpus
*/
var findMatch = function (inValue, search) {
var matchStart;
var value = (inValue || '').toLowerCase();
var matches = search
.filter(function (s) { return !!s && s.toLowerCase; })
.map(function (s) {
matchStart = value.indexOf(s.toLowerCase());
return matchStart !== -1
? {
searchText: s,
startPos: matchStart,
}
: undefined;
})
.filter(function (m) { return !!m; })
.map(function (m) { return m; }); // This last line is only here to make TS happy
return matches[0];
};
/**
* Highlight search results within a string using HTML spans
*/
var highlightSearchResult = function (value, searchText, options) {
var match = findMatch(value, [searchText]);
var match = (0, moxb_1.findTextMatch)(value, [searchText]);
var className = options.className, style = options.style;

@@ -35,3 +15,3 @@ var begin = className ? "<span class=\"".concat(className, "\" >") : "<span style=\"".concat((0, util_1.styleToString)(style), "\">");

if (match) {
return value.replace(RegExp(match.searchText, 'i'), function (text) { return "".concat(begin).concat(text).concat(end); });
return "".concat(value.substring(0, match.startPos)).concat(begin).concat(value.substring(match.startPos, match.startPos + match.searchText.length)).concat(end).concat(value.substring(match.startPos + match.searchText.length));
}

@@ -43,2 +23,2 @@ else {

exports.highlightSearchResult = highlightSearchResult;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlI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{

"dependencies": {
"@moxb/moxb": "^0.3.78"
"@moxb/moxb": "^0.3.79"
},

@@ -75,3 +75,3 @@ "peerDependencies": {

},
"gitHead": "059217377e9325262b5f4e6bcfd6de4ce4fc6dac"
"gitHead": "10beacc33689e81e1286632aad4041b95be1ba73"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc