Version 1
[yaffs-website] / node_modules / grunt-legacy-util / node_modules / lodash / startsWith.js
diff --git a/node_modules/grunt-legacy-util/node_modules/lodash/startsWith.js b/node_modules/grunt-legacy-util/node_modules/lodash/startsWith.js
new file mode 100644 (file)
index 0000000..a7c170e
--- /dev/null
@@ -0,0 +1,32 @@
+var baseClamp = require('./_baseClamp'),
+    toInteger = require('./toInteger'),
+    toString = require('./toString');
+
+/**
+ * Checks if `string` starts with the given target string.
+ *
+ * @static
+ * @memberOf _
+ * @category String
+ * @param {string} [string=''] The string to search.
+ * @param {string} [target] The string to search for.
+ * @param {number} [position=0] The position to search from.
+ * @returns {boolean} Returns `true` if `string` starts with `target`, else `false`.
+ * @example
+ *
+ * _.startsWith('abc', 'a');
+ * // => true
+ *
+ * _.startsWith('abc', 'b');
+ * // => false
+ *
+ * _.startsWith('abc', 'b', 1);
+ * // => true
+ */
+function startsWith(string, target, position) {
+  string = toString(string);
+  position = baseClamp(toInteger(position), 0, string.length);
+  return string.lastIndexOf(target, position) == position;
+}
+
+module.exports = startsWith;