New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

n-gram

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

n-gram - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

14

index.d.ts

@@ -8,14 +8,18 @@ /**

n: number
): (value?: string | string[]) => (string | string[])[]
): <T extends string | string[]>(value?: T) => T[]
/**
* Create n-grams from a given value.
*
* @param {string|string[]} [value]
* @template {string|string[]} T
* @param {T} [value]
* @returns {T[]}
*/
export function bigram(value?: string | string[]): (string | string[])[]
export function bigram<T extends string | string[]>(value?: T): T[]
/**
* Create n-grams from a given value.
*
* @param {string|string[]} [value]
* @template {string|string[]} T
* @param {T} [value]
* @returns {T[]}
*/
export function trigram(value?: string | string[]): (string | string[])[]
export function trigram<T extends string | string[]>(value?: T): T[]

@@ -24,10 +24,12 @@ export var bigram = nGram(2)

*
* @param {string|string[]} [value]
* @template {string|string[]} T
* @param {T} [value]
* @returns {T[]}
*/
function grams(value) {
/** @type {(typeof value)[]} */
/** @type {T[]} */
var nGrams = []
/** @type {number} */
var index
/** @type {typeof value} */
/** @type {string|string[]} */
var source

@@ -47,2 +49,3 @@

while (index--) {
// @ts-ignore
nGrams[index] = source.slice(index, index + n)

@@ -49,0 +52,0 @@ }

{
"name": "n-gram",
"version": "2.0.0",
"version": "2.0.1",
"description": "Get n-grams from text",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -24,3 +24,3 @@ # n-gram

```js
import {bigram, trigram, nGram} = require('n-gram')
import {bigram, trigram, nGram} from 'n-gram'

@@ -49,3 +49,3 @@ bigram('n-gram') // ['n-', '-g', 'gr', 'ra', 'am']

Want padding?
Use something like the following: `nGram(2)(' ' + value + ' ');`
Use something like the following: `nGram(2)(' ' + value + ' ')`

@@ -52,0 +52,0 @@ ### `bigram(value)`

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