How to use the chrono-node.casual function in chrono-node

To help you get started, we’ve selected a few chrono-node examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gahabeen / jsonframe-cheerio / index.js View on Github external
}
		}

	} else if (["address", "add"].includes(extractor)) {
		result = addressit(data)
	} else if (["email", "mail", "@"].includes(extractor)) {
		if (multiple) {
			result = data.match(emailRegex) || data
			if (_.isArray(result) && result.length === 1) {
				result = result[0]
			}
		} else {
			result = data.match(emailRegex) !== null ? data.match(emailRegex)[0] : ""
		}
	} else if (["date", "d"].includes(extractor)) {
		let date = chrono.casual.parseDate(data)
		if (date) {
			result = date.toString()
		} else {
			result = ""
		}
	} else if (["fullName", "prenom", "firstName", "nom", "lastName", "initials", "suffix", "salutation"].includes(extractor)) {
		// compact data before to parse it
		result = humanname.parse(filterData(data, "cmp"))
		if ("fullName".includes(extractor)) {
			// return the object
		} else if (["firstName", "prenom"].includes(extractor)) {
			result = result.firstName
		} else if (["lastName", "nom"].includes(extractor)) {
			result = result.lastName
		} else if ("initials".includes(extractor)) {
			result = result.initials
github gahabeen / jsonframe-cheerio / modules / extractors.fn.js View on Github external
}
		}

	} else if (["address", "add"].includes(extractor)) {
		result = addressit(data)
	} else if (["email", "mail"].includes(extractor)) {
		if (multiple) {
			result = data.match(emailRegex) || data
			if (_.isArray(result) && result.length === 1) {
				result = result[0]
			}
		} else {
			result = data.match(emailRegex) !== null ? data.match(emailRegex)[0] : ""
		}
	} else if (["date", "d"].includes(extractor)) {
		let date = chrono.casual.parseDate(data)
		if (date) {
			result = date.toString()
		} else {
			result = ""
		}
	} else if (["fullName", "prenom", "firstName", "nom", "lastName", "initials", "suffix", "salutation"].includes(extractor)) {
		// compact data before to parse it
		result = humanname.parse(filterData(data, "cmp"))
		if ("fullName".includes(extractor)) {
			// return the object
		} else if (["firstName", "prenom"].includes(extractor)) {
			result = result.firstName
		} else if (["lastName", "nom"].includes(extractor)) {
			result = result.lastName
		} else if ("initials".includes(extractor)) {
			result = result.initials

chrono-node

A natural language date parser in Javascript

MIT
Latest version published 2 months ago

Package Health Score

83 / 100
Full package analysis

Similar packages